/*!

Copyright (c) 2001 - 2025 Qualcomm Technologies International, Ltd.
All Rights Reserved.
Qualcomm Technologies International, Ltd. Confidential and Proprietary.

(C) COPYRIGHT Cambridge Consultants Ltd 1998

\file   dm_prim.h

\brief  This file contains Bluetooth Device Manager specific primitives.
*/
#ifndef BLUESTACK__DM_PRIM_H
#define BLUESTACK__DM_PRIM_H

#include "hci.h"

#ifdef __cplusplus
extern "C" {
#endif

/* search_string="dm_prim_t" */
/* conversion_rule="ADD_UNDERSCORE_AND_UPPERCASE_T" */

/*============================================================================*
                    Header files on which this one depends
 *============================================================================*/

/* None */

/*============================================================================*
                       Interface #defined parameters
 *============================================================================*/

#define DEFAULT_ACL_PACKET_TYPE (HCI_PKT_DM1 | HCI_PKT_DH1 | HCI_PKT_DM3 | HCI_PKT_DH3 | HCI_PKT_DM5 | HCI_PKT_DH5)
#define DEFAULT_SCO_PACKET_TYPE (HCI_PKT_HV3)

/* dm_prim_t allocation
 *
 * 0x0000 -> 0x0100 HCI events
 * 0x0100 -> 0x0180 DM_ADV_EXT_PRIM
 * 0x0180 -> 0x0200 DM_INTERNAL (RESERVED for internal DM communication)
 * 0x0200 -> 0x0280 DM_AMPM
 * 0x0280 -> 0x0300 DM_SYNC
 * 0x0300 -> 0x0380 DM_PRIV
 * 0x0380 -> 0x0400 DM_SM
 * 0x0400 ->        HCI commands
 * (but bit 10 - 0x0200 - which is the top bit of the OGC is used to indicate
 * whether the command requires a connection handle to be filled in by the DM)
 */

/* send_to_hci_with_handle */
#define DM_HCI_WITH_HANDLE          0x0200
#define DM_HCI_OP_CODE_MASK         (~DM_HCI_WITH_HANDLE)

/* DM_HCI_ types */
#define DM_HCI_EVENT_PRIM           0x0010
#define DM_LC_PRIM                  HCI_LINK
#define DM_LP_PRIM                  HCI_POLICY
#define DM_BB_PRIM                  HCI_HOST_BB
#define DM_INF_PRIM                 HCI_INFO
#define DM_STATUS_PRIM              HCI_STATUS
#define DM_TEST_PRIM                HCI_TEST
#define DM_ULP_PRIM                 HCI_ULP
#define DM_OGF_MASK                 0xFC00
#define DM_HCI_COMMANDS             DM_LC_PRIM

/* DM Advertising Extensions primitives for EA, ES, PA, PS */
#define DM_ADV_EXT_DOWN_PRIM        0x0100
#define DM_ADV_EXT_UP_PRIM          0x0140
#define DM_ADV_EXT_PRIM             DM_ADV_EXT_DOWN_PRIM
/* DM types used internally - not exported to the application. */
#define DM_INTERNAL_DOWN_PRIM       0x0180
#define DM_INTERNAL_UP_PRIM         0x01C0
#define DM_INERNAL_PRIM             DM_INTERNAL_DOWN_PRIM
/* Native DM types - not DM_HCI_ */
/* AMPM interface to DM */
#define DM_AMPM_DOWN_PRIM           0x0200
#define DM_AMPM_UP_PRIM             0x0240
#define DM_AMPM_PRIM                DM_AMPM_DOWN_PRIM
/* SCO primitives */
#define DM_SYNC_DOWN_PRIM           0x0280
#define DM_SYNC_UP_PRIM             0x02C0
#define DM_SYNC_PRIM                DM_SYNC_DOWN_PRIM
/* Commands specific to this Device Manager */
#define DM_PRIV_DOWN_PRIM           0x0300
#define DM_PRIV_UP_PRIM             0x0340
#define DM_PRIV_PRIM                DM_PRIV_DOWN_PRIM
/* Security manager primitives */
#define DM_SM_DOWN_PRIM             0x0380
#define DM_SM_UP_PRIM               0x03C0
#define DM_SM_PRIM                  DM_SM_DOWN_PRIM

/* 64 primitives is enough for anyone... */
#define DM_TYPE_MASK                0x003F
#define DM_GROUP_MASK               0xFFC0

/* First add your primitive here... */
typedef enum dm_prim_tag
{
    /* DM_AM_REGISTER_REQ for old API.

       This is just to help catch an application sending DM_AM_REGISTER_REQ
       using the wrong API. If you do this from the VM (which should be
       quite difficult) then the firmware will panic. If you do it via an
       external physical interface (setting the top bit of the phandle) then
       the firmware will reply with INVALID_PHANDLE.*/
    ENUM_DM_AM_REGISTER_WRONG_API_REQ = 0,
    ENUM_DM_AM_REGISTER_WRONG_API_CFM = 1,

    /*-------------------------------------------------------------
      Device Manager private primitives
      Included here are also special DM_HCI commands that the DM
      must intercept before sending them across HCI.
      ---------------------------------------------------------------*/
    ENUM_DM_AM_REGISTER_REQ = DM_PRIV_DOWN_PRIM,
    ENUM_DM_SET_BT_VERSION_REQ,
    ENUM_DM_WRITE_CACHED_PAGE_MODE_REQ,
    ENUM_DM_WRITE_CACHED_CLOCK_OFFSET_REQ,
    ENUM_DM_CLEAR_PARAM_CACHE_REQ,
    ENUM_DM_LP_WRITE_POWERSTATES_REQ,
    ENUM_DM_SET_DEFAULT_LINK_POLICY_REQ,
    ENUM_DM_ACL_OPEN_REQ,
    ENUM_DM_ACL_CLOSE_REQ,
    ENUM_DM_HCI_REMOTE_NAME_REQUEST_REQ,
    ENUM_DM_HCI_SNIFF_MODE_REQ,
    ENUM_DM_HCI_EXIT_SNIFF_MODE_REQ,
    ENUM_DM_HCI_SWITCH_ROLE_REQ = (ENUM_DM_HCI_EXIT_SNIFF_MODE_REQ + 3),
    ENUM_DM_HCI_WRITE_LINK_POLICY_SETTINGS_REQ,
    ENUM_DM_LP_WRITE_ROLESWITCH_POLICY_REQ,
    ENUM_DM_LP_WRITE_ALWAYS_MASTER_DEVICES_REQ,
    ENUM_DM_HCI_WRITE_SCAN_ENABLE_REQ,
    ENUM_DM_HCI_ULP_SET_ADVERTISE_ENABLE_REQ,
    ENUM_DM_HCI_ULP_SET_ADVERTISING_PARAMETERS_REQ,
    ENUM_DM_SET_BLE_CONNECTION_PARAMETERS_REQ,
    ENUM_DM_BLE_UPDATE_CONNECTION_PARAMETERS_REQ,
    ENUM_DM_HCI_ULP_SET_SCAN_PARAMETERS_REQ,
    ENUM_DM_HCI_ULP_SET_SCAN_ENABLE_REQ,
    ENUM_DM_HANDLE_DEVICE_BLACK_LIST_REQ,
    ENUM_DM_HCI_CHANGE_ACL_CONN_PKT_TYPE_REQ,
    ENUM_DM_BLE_ACCEPT_CONNECTION_PAR_UPDATE_RSP,
    ENUM_DM_HCI_CSB_TX_TIMEOUT_RSP, /* Response to DM_HCI_CSB_TIMEOUT_IND */
    ENUM_DM_HCI_CSB_RX_TIMEOUT_RSP, /* Response to DM_HCI_CSB_TIMEOUT_IND */
    ENUM_DM_CONTROLLER_READY_NTF, /* Controller ready to be interrogated */
    ENUM_DM_CRYPTO_GENERATE_PUBLIC_PRIVATE_KEY_REQ,
    ENUM_DM_CRYPTO_GENERATE_SHARED_SECRET_KEY_REQ,
    ENUM_DM_CRYPTO_ENCRYPT_REQ,
    ENUM_DM_CRYPTO_HASH_REQ,
    ENUM_DM_ULP_ENABLE_ZERO_SLAVE_LATENCY_REQ,
    ENUM_DM_ULP_SET_PHY_REQ,
    ENUM_DM_ULP_SET_DEFAULT_PHY_REQ,
    ENUM_DM_VS_REGISTER_REQ,
    ENUM_DM_VS_COMMAND_REQ,
    ENUM_DM_WRITE_SC_HOST_SUPPORT_OVERRIDE_REQ,
    ENUM_DM_READ_SC_HOST_SUPPORT_OVERRIDE_MAX_BD_ADDR_REQ,
    ENUM_DM_SET_LINK_BEHAVIOR_REQ,
    ENUM_DM_CRYPTO_DECRYPT_REQ,
    ENUM_DM_CRYPTO_AES_CTR_REQ,
    ENUM_DM_ULP_ENHANCED_READ_TRANSMIT_POWER_LEVEL_REQ,
    ENUM_DM_ULP_READ_REMOTE_TRANSMIT_POWER_LEVEL_REQ,
    ENUM_DM_ULP_SET_PATH_LOSS_REPORTING_PARAMETERS_REQ,
    ENUM_DM_ULP_SET_PATH_LOSS_REPORTING_ENABLE_REQ,
    ENUM_DM_ULP_SET_TRANSMIT_POWER_REPORTING_ENABLE_REQ,
    ENUM_DM_HCI_ULP_SET_DEFAULT_SUBRATE_REQ,
    ENUM_DM_HCI_ULP_SUBRATE_CHANGE_REQ,
    ENUM_DM_ULP_SET_DATA_RELATED_ADDRESS_CHANGES_REQ,
    ENUM_DM_ULP_READ_PHY_REQ,

    ENUM_DM_AM_REGISTER_CFM = DM_PRIV_UP_PRIM,
    ENUM_DM_SET_BT_VERSION_CFM,
    ENUM_DM_WRITE_CACHED_PAGE_MODE_CFM,
    ENUM_DM_WRITE_CACHED_CLOCK_OFFSET_CFM,
    ENUM_DM_CLEAR_PARAM_CACHE_CFM,
    ENUM_DM_LP_WRITE_POWERSTATES_CFM,
    ENUM_DM_ACL_OPEN_CFM,
    ENUM_DM_ACL_OPENED_IND,
    ENUM_DM_ACL_CLOSED_IND,
    ENUM_DM_HCI_REMOTE_NAME_CFM,
    ENUM_DM_HCI_SWITCH_ROLE_CFM,
    ENUM_DM_LP_WRITE_ROLESWITCH_POLICY_CFM,
    ENUM_DM_BLUESTACK_STATE_TRANSITION_ENTRY_IND,       /* DEBUG */
    ENUM_DM_BLUESTACK_STATE_TRANSITION_EXIT_IND,        /* DEBUG */
    ENUM_DM_LP_WRITE_ALWAYS_MASTER_DEVICES_CFM,
    ENUM_DM_BAD_MESSAGE_IND,
    ENUM_DM_SET_BLE_CONNECTION_PARAMETERS_CFM,
    ENUM_DM_BLE_UPDATE_CONNECTION_PARAMETERS_CFM,
    ENUM_DM_HANDLE_DEVICE_BLACK_LIST_CFM,
    ENUM_DM_HCI_CHANGE_ACL_CONN_PKT_TYPE_CFM,
    ENUM_DM_ACL_CONN_HANDLE_IND,
    ENUM_DM_BLE_ACCEPT_CONNECTION_PAR_UPDATE_IND,
    ENUM_DM_ACL_CONN_START_IND,
    ENUM_DM_ULP_ADV_PARAM_UPDATE_IND,
    ENUM_DM_CRYPTO_GENERATE_PUBLIC_PRIVATE_KEY_CFM,
    ENUM_DM_CRYPTO_GENERATE_SHARED_SECRET_KEY_CFM,
    ENUM_DM_CRYPTO_ENCRYPT_CFM,
    ENUM_DM_CRYPTO_HASH_CFM,
    ENUM_DM_ULP_ENABLE_ZERO_SLAVE_LATENCY_CFM,
    ENUM_DM_HCI_ULP_CHANNEL_SELECTION_ALGORITHM_IND,
    ENUM_DM_ULP_SET_PHY_CFM,
    ENUM_DM_ULP_SET_DEFAULT_PHY_CFM,
    ENUM_DM_ULP_PHY_UPDATE_IND,
    ENUM_DM_VS_REGISTER_CFM,
    ENUM_DM_VS_COMMAND_CFM,
    ENUM_DM_VS_EVENT_IND,
    ENUM_DM_WRITE_SC_HOST_SUPPORT_OVERRIDE_CFM,
    ENUM_DM_READ_SC_HOST_SUPPORT_OVERRIDE_MAX_BD_ADDR_CFM,
    ENUM_DM_ACL_CLOSE_CFM,
    ENUM_DM_SET_LINK_BEHAVIOR_CFM,
    ENUM_DM_CRYPTO_DECRYPT_CFM,
    ENUM_DM_CRYPTO_AES_CTR_CFM,
    ENUM_DM_ULP_ENHANCED_READ_TRANSMIT_POWER_LEVEL_CFM,
    ENUM_DM_ULP_READ_REMOTE_TRANSMIT_POWER_LEVEL_CFM,
    ENUM_DM_ULP_TRANSMIT_POWER_REPORTING_IND,
    ENUM_DM_ULP_SET_PATH_LOSS_REPORTING_PARAMETERS_CFM,
    ENUM_DM_ULP_SET_PATH_LOSS_REPORTING_ENABLE_CFM,
    ENUM_DM_ULP_SET_TRANSMIT_POWER_REPORTING_ENABLE_CFM,
    ENUM_DM_ULP_PATH_LOSS_THRESHOLD_IND,
    ENUM_DM_HCI_ULP_SET_DEFAULT_SUBRATE_CFM,
    ENUM_DM_HCI_ULP_SUBRATE_CHANGE_CFM,
    ENUM_DM_HCI_ULP_SUBRATE_CHANGE_IND,
    ENUM_DM_ULP_SET_DATA_RELATED_ADDRESS_CHANGES_CFM,
    ENUM_DM_ULP_READ_PHY_CFM,

    /*-------------------------------------------------------------
      Security Management Primitives
      ---------------------------------------------------------------*/
    ENUM_DM_SM_INIT_REQ = DM_SM_DOWN_PRIM,
    ENUM_DM_SM_REGISTER_REQ,
    ENUM_DM_SM_UNREGISTER_REQ,
    ENUM_DM_SM_REGISTER_OUTGOING_REQ,
    ENUM_DM_SM_UNREGISTER_OUTGOING_REQ,
    ENUM_DM_SM_ACCESS_REQ,
    ENUM_DM_SM_ADD_DEVICE_REQ,
    ENUM_DM_SM_REMOVE_DEVICE_REQ,
    ENUM_DM_SM_KEY_REQUEST_RSP,
    ENUM_DM_SM_PIN_REQUEST_RSP,
    ENUM_DM_SM_AUTHORISE_RSP,
    ENUM_DM_SM_AUTHENTICATE_REQ,
    ENUM_DM_SM_ENCRYPT_REQ,
    ENUM_DM_SM_IO_CAPABILITY_REQUEST_RSP,
    ENUM_DM_SM_BONDING_REQ,
    ENUM_DM_SM_BONDING_CANCEL_REQ,
    ENUM_DM_SM_READ_DEVICE_REQ,
    ENUM_DM_SM_IO_CAPABILITY_REQUEST_NEG_RSP,
    ENUM_DM_SM_USER_CONFIRMATION_REQUEST_RSP,
    ENUM_DM_SM_USER_CONFIRMATION_REQUEST_NEG_RSP,
    ENUM_DM_SM_USER_PASSKEY_REQUEST_RSP,
    ENUM_DM_SM_USER_PASSKEY_REQUEST_NEG_RSP,
    ENUM_DM_SM_SECURITY_REQ,
    ENUM_DM_SM_DATA_SIGN_REQ = (ENUM_DM_SM_SECURITY_REQ + 3),
    ENUM_DM_SM_KEY_REQUEST_NEG_RSP,
    ENUM_DM_SM_LINK_KEY_REQUEST_RSP,    /* Deprecated */
    ENUM_DM_SM_READ_LOCAL_OOB_DATA_REQ = (ENUM_DM_SM_LINK_KEY_REQUEST_RSP + 2),
    ENUM_DM_SM_SEND_KEYPRESS_NOTIFICATION_REQ,
    ENUM_DM_SM_GENERATE_LOCAL_KEY_REQ,
    ENUM_DM_SM_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_REQ,
    ENUM_DM_SM_AUTO_CONFIGURE_LOCAL_ADDRESS_REQ,
    ENUM_DM_SM_READ_RANDOM_ADDRESS_REQ,
    ENUM_DM_SM_SERVICE_REGISTER_REQ,
    ENUM_DM_SM_SERVICE_REGISTER_OUTGOING_REQ,
    ENUM_DM_SM_READ_LOCAL_IRK_REQ,
    ENUM_DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_RSP,
    ENUM_DM_SM_SIRK_OPERATION_REQ,
    ENUM_DM_SM_CONFIG_REQ,
    ENUM_DM_SM_ENCRYPT_DATA_REQ,

    ENUM_DM_SM_INIT_CFM = DM_SM_UP_PRIM,
    ENUM_DM_SM_ACCESS_CFM,
    ENUM_DM_SM_ADD_DEVICE_CFM,
    ENUM_DM_SM_REMOVE_DEVICE_CFM,
    ENUM_DM_SM_KEY_REQUEST_IND,
    ENUM_DM_SM_PIN_REQUEST_IND,
    ENUM_DM_SM_KEYS_IND,
    ENUM_DM_SM_AUTHORISE_IND,
    ENUM_DM_SM_AUTHENTICATE_CFM,
    ENUM_DM_SM_ENCRYPT_CFM,
    ENUM_DM_SM_ENCRYPTION_CHANGE_IND,
    ENUM_DM_SM_IO_CAPABILITY_RESPONSE_IND,
    ENUM_DM_SM_IO_CAPABILITY_REQUEST_IND,
    ENUM_DM_SM_SIMPLE_PAIRING_COMPLETE_IND,
    ENUM_DM_SM_USER_CONFIRMATION_REQUEST_IND,
    ENUM_DM_SM_USER_PASSKEY_REQUEST_IND,
    ENUM_DM_SM_USER_PASSKEY_NOTIFICATION_IND,
    ENUM_DM_SM_KEYPRESS_NOTIFICATION_IND,
    ENUM_DM_SM_BONDING_CFM,
    ENUM_DM_SM_READ_DEVICE_CFM,
    ENUM_DM_SM_ACCESS_IND,
    ENUM_DM_SM_REGISTER_CFM,
    ENUM_DM_SM_UNREGISTER_CFM,
    ENUM_DM_SM_REGISTER_OUTGOING_CFM,
    ENUM_DM_SM_UNREGISTER_OUTGOING_CFM,
    ENUM_DM_SM_SECURITY_CFM,
    ENUM_DM_SM_SECURITY_IND,
    ENUM_DM_SM_DATA_SIGN_CFM = (ENUM_DM_SM_SECURITY_IND + 3),
    ENUM_DM_SM_CSRK_COUNTER_CHANGE_IND,
    ENUM_DM_SM_LINK_KEY_IND,            /* Deprecated */
    ENUM_DM_SM_LINK_KEY_REQUEST_IND,    /* Deprecated */
    ENUM_DM_SM_READ_LOCAL_OOB_DATA_CFM,
    ENUM_DM_SM_GENERATE_LOCAL_KEY_CFM,
    ENUM_DM_SM_GENERATE_LOCAL_KEY_IND,
    ENUM_DM_SM_LOCAL_KEY_DELETED_IND,
    ENUM_DM_SM_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_CFM,
    ENUM_DM_SM_AUTO_CONFIGURE_LOCAL_ADDRESS_CFM,
    ENUM_DM_SM_READ_RANDOM_ADDRESS_CFM,
    ENUM_DM_SM_READ_LOCAL_IRK_CFM,
    ENUM_DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_IND,
    ENUM_DM_SM_SIRK_OPERATION_CFM,
    ENUM_DM_SM_CONFIG_CFM,
    ENUM_DM_SM_ENCRYPT_DATA_CFM,
    ENUM_DM_SM_ENCRYPTION_CHANGE_KEY_SIZE_IND,

    /*-------------------------------------------------------------
      Internal Device Manager/AMP Manager Interface
      ---------------------------------------------------------------*/
    ENUM_DM_AMPM_REGISTER_REQ = DM_AMPM_DOWN_PRIM,
    ENUM_DM_AMPM_CONNECT_RSP,
    ENUM_DM_AMPM_CONNECT_CHANNEL_RSP,
    ENUM_DM_AMPM_DISCONNECT_CHANNEL_RSP,
    ENUM_DM_AMPM_DISCONNECT_REQ,
    ENUM_DM_AMPM_READ_BD_ADDR_REQ,
    ENUM_DM_AMPM_VERIFY_PHYSICAL_LINK_RSP,
    ENUM_DM_AMPM_READ_DATA_BLOCK_SIZE_RSP,
    ENUM_DM_AMPM_NUMBER_COMPLETED_DATA_BLOCKS_REQ,

    ENUM_DM_AMPM_REGISTER_CFM = DM_AMPM_UP_PRIM,
    ENUM_DM_AMPM_CONNECT_IND,
    ENUM_DM_AMPM_CONNECT_CHANNEL_IND,
    ENUM_DM_AMPM_DISCONNECT_CHANNEL_IND,
    ENUM_DM_AMPM_LINK_KEY_NOTIFICATION_IND,
    ENUM_DM_AMPM_READ_BD_ADDR_CFM,
    ENUM_DM_AMPM_VERIFY_PHYSICAL_LINK_IND,
    ENUM_DM_AMPM_READ_DATA_BLOCK_SIZE_IND,
    ENUM_DM_AMPM_SIMPLE_PAIRING_ENABLED_IND,
    ENUM_DM_AMPM_REMOTE_FEATURES_IND,

    /*-------------------------------------------------------------
      Internal Device Manager HCI data interface. Not for application use.
      ---------------------------------------------------------------*/
    ENUM_DM_DATA_FROM_HCI_REQ = DM_INTERNAL_DOWN_PRIM,
    ENUM_DM_DATA_TO_HCI_IND = DM_INTERNAL_UP_PRIM,

    /*-------------------------------------------------------------
      Synchronous and Isochronous Connection Interface Primitives
      ---------------------------------------------------------------*/
    ENUM_DM_SYNC_REGISTER_REQ = DM_SYNC_DOWN_PRIM,
    ENUM_DM_SYNC_UNREGISTER_REQ,
    ENUM_DM_SYNC_CONNECT_REQ,
    ENUM_DM_SYNC_CONNECT_RSP,
    ENUM_DM_SYNC_DISCONNECT_REQ,
    ENUM_DM_SYNC_RENEGOTIATE_REQ,
    ENUM_DM_ISOC_REGISTER_REQ,
    ENUM_DM_ISOC_CONFIGURE_CIG_REQ,
    ENUM_DM_ISOC_REMOVE_CIG_REQ,
    ENUM_DM_ISOC_CIS_CONNECT_REQ,
    ENUM_DM_ISOC_CIS_CONNECT_RSP,
    ENUM_DM_ISOC_CIS_DISCONNECT_REQ,
    ENUM_DM_ISOC_ISO_TRANSMIT_TEST_REQ,
    ENUM_DM_ISOC_ISO_RECEIVE_TEST_REQ,
    ENUM_DM_ISOC_ISO_READ_TEST_COUNTERS_REQ,
    ENUM_DM_ISOC_SETUP_ISO_DATA_PATH_REQ,
    ENUM_DM_ISOC_REMOVE_ISO_DATA_PATH_REQ,
    ENUM_DM_ISOC_CREATE_BIG_REQ,
    ENUM_DM_ISOC_TERMINATE_BIG_REQ,
    ENUM_DM_ISOC_BIG_CREATE_SYNC_REQ,
    ENUM_DM_ISOC_BIG_TERMINATE_SYNC_REQ,
    ENUM_DM_ISOC_READ_ISO_LINK_QUALITY_REQ,
    ENUM_DM_ISOC_CONFIGURE_CIG_TEST_REQ,
    ENUM_DM_ISOC_CREATE_BIG_TEST_REQ,
    ENUM_DM_ISOC_BROADCAST_DEVICE_SECURITY_REQ,

    ENUM_DM_SYNC_REGISTER_CFM = DM_SYNC_UP_PRIM,
    ENUM_DM_SYNC_UNREGISTER_CFM,
    ENUM_DM_SYNC_CONNECT_CFM,
    ENUM_DM_SYNC_CONNECT_IND,
    ENUM_DM_SYNC_DISCONNECT_CFM,
    ENUM_DM_SYNC_RENEGOTIATE_CFM,
    ENUM_DM_SYNC_CONNECT_COMPLETE_IND,
    ENUM_DM_SYNC_DISCONNECT_IND,
    ENUM_DM_SYNC_RENEGOTIATE_IND,
    ENUM_DM_ISOC_REGISTER_CFM,
    ENUM_DM_ISOC_CONFIGURE_CIG_CFM,
    ENUM_DM_ISOC_REMOVE_CIG_CFM,
    ENUM_DM_ISOC_CIS_CONNECT_IND,
    ENUM_DM_ISOC_CIS_CONNECT_CFM,
    ENUM_DM_ISOC_CIS_DISCONNECT_CFM,
    ENUM_DM_ISOC_CIS_DISCONNECT_IND,
    ENUM_DM_ISOC_ISO_TRANSMIT_TEST_CFM,
    ENUM_DM_ISOC_ISO_RECEIVE_TEST_CFM,
    ENUM_DM_ISOC_ISO_READ_TEST_COUNTERS_CFM,
    ENUM_DM_ISOC_SETUP_ISO_DATA_PATH_CFM,
    ENUM_DM_ISOC_REMOVE_ISO_DATA_PATH_CFM,
    ENUM_DM_ISOC_CREATE_BIG_CFM,
    ENUM_DM_ISOC_TERMINATE_BIG_CFM,
    ENUM_DM_ISOC_BIG_CREATE_SYNC_CFM,
    ENUM_DM_ISOC_BIG_TERMINATE_SYNC_IND,
    ENUM_DM_ISOC_READ_ISO_LINK_QUALITY_CFM,
    ENUM_DM_ISOC_CONFIGURE_CIG_TEST_CFM,
    ENUM_DM_ISOC_CREATE_BIG_TEST_CFM,
    ENUM_DM_ISOC_BROADCAST_DEVICE_SECURITY_CFM,

    /*-------------------------------------------------------------
      Advertising Extensions Interface Primitives
      ---------------------------------------------------------------*/
    ENUM_DM_ULP_GET_ADV_SCAN_CAPABILITIES_REQ = DM_ADV_EXT_DOWN_PRIM,
    ENUM_DM_ULP_EXT_ADV_SET_RANDOM_ADDR_REQ,
    ENUM_DM_ULP_EXT_ADV_REGISTER_APP_ADV_SET_REQ,
    ENUM_DM_ULP_EXT_ADV_UNREGISTER_APP_ADV_SET_REQ,
    ENUM_DM_ULP_EXT_ADV_SET_PARAMS_REQ,
    ENUM_DM_ULP_EXT_ADV_ENABLE_REQ,
    ENUM_DM_ULP_EXT_ADV_READ_MAX_ADV_DATA_LEN_REQ,
    ENUM_DM_ULP_EXT_SCAN_GET_GLOBAL_PARAMS_REQ,
    ENUM_DM_ULP_EXT_SCAN_SET_GLOBAL_PARAMS_REQ,
    ENUM_DM_ULP_EXT_SCAN_REGISTER_SCANNER_REQ,
    ENUM_DM_ULP_EXT_SCAN_UNREGISTER_SCANNER_REQ,
    ENUM_DM_ULP_EXT_SCAN_CONFIGURE_SCANNER_REQ,
    ENUM_DM_ULP_EXT_SCAN_ENABLE_SCANNERS_REQ,
    ENUM_DM_ULP_EXT_SCAN_GET_CTRL_SCAN_INFO_REQ,
    ENUM_DM_ULP_PERIODIC_ADV_SET_PARAMS_REQ,
    ENUM_DM_ULP_PERIODIC_ADV_READ_MAX_ADV_DATA_LEN_REQ,
    ENUM_DM_ULP_PERIODIC_ADV_START_REQ,
    ENUM_DM_ULP_PERIODIC_ADV_STOP_REQ,
    ENUM_DM_ULP_PERIODIC_ADV_SET_TRANSFER_REQ,
    ENUM_DM_ULP_PERIODIC_SCAN_START_FIND_TRAINS_REQ,
    ENUM_DM_ULP_PERIODIC_SCAN_STOP_FIND_TRAINS_REQ,
    ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_REQ,
    ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CANCEL_REQ,
    ENUM_DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_ENABLE_REQ,
    ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TERMINATE_REQ,
    ENUM_DM_ULP_PERIODIC_SCAN_SYNC_LOST_RSP,
    ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_REQ,
    ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_PARAMS_REQ,
    ENUM_DM_ULP_EXT_ADV_MULTI_ENABLE_REQ,
    ENUM_DM_ULP_EXT_ADV_SETS_INFO_REQ,
    ENUM_DM_ULP_PERIODIC_ADV_ENABLE_REQ,
    ENUM_DM_ULP_EXT_ADV_SET_PARAMS_V2_REQ,
    ENUM_DM_ULP_EXT_ADV_GET_ADDR_REQ,

    ENUM_DM_ULP_GET_ADV_SCAN_CAPABILITIES_CFM = DM_ADV_EXT_UP_PRIM,
    ENUM_DM_ULP_EXT_ADV_SET_RANDOM_ADDR_CFM,
    ENUM_DM_ULP_EXT_ADV_REGISTER_APP_ADV_SET_CFM,
    ENUM_DM_ULP_EXT_ADV_UNREGISTER_APP_ADV_SET_CFM,
    ENUM_DM_ULP_EXT_ADV_SET_PARAMS_CFM,
    ENUM_DM_ULP_EXT_ADV_ENABLE_CFM,
    ENUM_DM_ULP_EXT_ADV_READ_MAX_ADV_DATA_LEN_CFM,
    ENUM_DM_ULP_EXT_SCAN_GET_GLOBAL_PARAMS_CFM,
    ENUM_DM_ULP_EXT_SCAN_SET_GLOBAL_PARAMS_CFM,
    ENUM_DM_ULP_EXT_SCAN_REGISTER_SCANNER_CFM,
    ENUM_DM_ULP_EXT_SCAN_UNREGISTER_SCANNER_CFM,
    ENUM_DM_ULP_EXT_SCAN_CONFIGURE_SCANNER_CFM,
    ENUM_DM_ULP_EXT_SCAN_ENABLE_SCANNERS_CFM,
    ENUM_DM_ULP_EXT_SCAN_GET_CTRL_SCAN_INFO_CFM,
    ENUM_DM_ULP_EXT_SCAN_CTRL_SCAN_INFO_IND,
    ENUM_DM_ULP_EXT_SCAN_FILTERED_ADV_REPORT_IND,
    ENUM_DM_ULP_PERIODIC_ADV_SET_PARAMS_CFM,
    ENUM_DM_ULP_PERIODIC_ADV_READ_MAX_ADV_DATA_LEN_CFM,
    ENUM_DM_ULP_PERIODIC_ADV_START_CFM,
    ENUM_DM_ULP_PERIODIC_ADV_STOP_CFM,
    ENUM_DM_ULP_PERIODIC_ADV_SET_TRANSFER_CFM,
    ENUM_DM_ULP_PERIODIC_SCAN_START_FIND_TRAINS_CFM,
    ENUM_DM_ULP_PERIODIC_SCAN_STOP_FIND_TRAINS_CFM,
    ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CFM,
    ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CANCEL_CFM,
    ENUM_DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_ENABLE_CFM,
    ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TERMINATE_CFM,
    ENUM_DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_IND,
    ENUM_DM_ULP_PERIODIC_SCAN_SYNC_LOST_IND,
    ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_CFM,
    ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_IND,
    ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_PARAMS_CFM,
    ENUM_DM_ULP_EXT_SCAN_DURATION_EXPIRED_IND,
    ENUM_DM_ULP_EXT_ADV_TERMINATED_IND,
    ENUM_DM_ULP_EXT_ADV_MULTI_ENABLE_CFM,
    ENUM_DM_ULP_EXT_ADV_SETS_INFO_CFM,
    ENUM_DM_ULP_PERIODIC_ADV_ENABLE_CFM,
    ENUM_DM_ULP_EXT_ADV_SET_PARAMS_V2_CFM,
    ENUM_DM_ULP_EXT_ADV_GET_ADDR_CFM,
    ENUM_DM_ULP_EXT_SCAN_TIMEOUT_IND,

    /*-------------------------------------------------------------
      HCI API primitives
      ---------------------------------------------------------------*/

    /******************************************************************************
      HCI Events
      *****************************************************************************/
    ENUM_DM_HCI_INQUIRY_RESULT_IND = DM_HCI_EVENT_PRIM,
    ENUM_DM_HCI_RETURN_LINK_KEYS_IND,
    ENUM_DM_HCI_MODE_CHANGE_EVENT_IND,
    ENUM_DM_HCI_INQUIRY_RESULT_WITH_RSSI_IND,
    ENUM_DM_HCI_SNIFF_SUB_RATING_IND,
    ENUM_DM_HCI_EXTENDED_INQUIRY_RESULT_IND,
    ENUM_DM_HCI_LINK_SUPERV_TIMEOUT_IND,
    ENUM_DM_HCI_REM_HOST_SUPPORTED_FEATURES_IND,
    ENUM_DM_HCI_CONN_PACKET_TYPE_CHANGED_IND,
    ENUM_DM_HCI_ULP_ADVERTISING_REPORT_IND,
    ENUM_DM_HCI_AUTHENTICATED_PAYLOAD_TIMEOUT_EXPIRED_IND,
    ENUM_DM_HCI_CSB_RECEIVE_IND,
    ENUM_DM_HCI_CSB_TIMEOUT_IND,
    ENUM_DM_HCI_CSB_CHANNEL_MAP_CHANGE_IND,
    ENUM_DM_HCI_SLAVE_PAGE_RESPONSE_TIMEOUT_IND,
    ENUM_DM_HCI_CSB_AFH_MAP_AVAILABLE_IND,
    ENUM_DM_HCI_ULP_BIGINFO_ADV_REPORT_IND,

    /******************************************************************************
      Link Control
      *****************************************************************************/

    /*-------------------------------------------------------------
      Downstream primitives
      ---------------------------------------------------------------*/
    ENUM_DM_HCI_INQUIRY_REQ                         = HCI_INQUIRY,
    ENUM_DM_HCI_INQUIRY_CANCEL_REQ                  = HCI_INQUIRY_CANCEL,
    ENUM_DM_HCI_PERIODIC_INQUIRY_MODE_REQ           = HCI_PERIODIC_INQUIRY_MODE,
    ENUM_DM_HCI_EXIT_PERIODIC_INQUIRY_MODE_REQ      = HCI_EXIT_PERIODIC_INQUIRY_MODE,
    ENUM_DM_HCI_CREATE_CONNECTION_CANCEL_REQ        = HCI_CREATE_CONNECTION_CANCEL,
    ENUM_DM_HCI_CHANGE_CONN_PKT_TYPE_REQ            = HCI_CHANGE_CONN_PKT_TYPE,
    ENUM_DM_HCI_CHANGE_CONN_LINK_KEY_REQ            = HCI_CHANGE_CONN_LINK_KEY              | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_MASTER_LINK_KEY_REQ                 = HCI_MASTER_LINK_KEY,
    ENUM_DM_HCI_REMOTE_NAME_REQ_CANCEL_REQ          = HCI_REMOTE_NAME_REQ_CANCEL,
    ENUM_DM_HCI_READ_REMOTE_SUPP_FEATURES_REQ       = HCI_READ_REMOTE_SUPP_FEATURES         | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_REMOTE_EXT_FEATURES_REQ        = HCI_READ_REMOTE_EXT_FEATURES          | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_REMOTE_VER_INFO_REQ            = HCI_READ_REMOTE_VER_INFO              | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_CLOCK_OFFSET_REQ               = HCI_READ_CLOCK_OFFSET                 | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_LMP_HANDLE_REQ                 = HCI_READ_LMP_HANDLE,
    ENUM_DM_HCI_TRUNCATED_PAGE_REQ                  = HCI_TRUNCATED_PAGE,
    ENUM_DM_HCI_TRUNCATED_PAGE_CANCEL_REQ           = HCI_TRUNCATED_PAGE_CANCEL,
    ENUM_DM_HCI_SET_CSB_REQ                         = HCI_SET_CSB,
    ENUM_DM_HCI_SET_CSB_RECEIVE_REQ                 = HCI_SET_CSB_RECEIVE,
    ENUM_DM_HCI_START_SYNCHRONIZATION_TRAIN_REQ     = HCI_START_SYNCHRONIZATION_TRAIN,
    ENUM_DM_HCI_RECEIVE_SYNCHRONIZATION_TRAIN_REQ   = HCI_RECEIVE_SYNCHRONIZATION_TRAIN,

    /*-------------------------------------------------------------
      Upstream primitives
      ---------------------------------------------------------------*/
    ENUM_DM_HCI_INQUIRY_CFM                         = HCI_INQUIRY                       | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_INQUIRY_CANCEL_CFM                  = HCI_INQUIRY_CANCEL                | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_PERIODIC_INQUIRY_MODE_CFM           = HCI_PERIODIC_INQUIRY_MODE         | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_EXIT_PERIODIC_INQUIRY_MODE_CFM      = HCI_EXIT_PERIODIC_INQUIRY_MODE    | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_CREATE_CONNECTION_CANCEL_CFM        = HCI_CREATE_CONNECTION_CANCEL      | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_CHANGE_CONN_LINK_KEY_CFM            = HCI_CHANGE_CONN_LINK_KEY,
    ENUM_DM_HCI_MASTER_LINK_KEY_CFM                 = HCI_MASTER_LINK_KEY               | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_REMOTE_NAME_REQ_CANCEL_CFM          = HCI_REMOTE_NAME_REQ_CANCEL        | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_REMOTE_SUPP_FEATURES_CFM       = HCI_READ_REMOTE_SUPP_FEATURES,
    ENUM_DM_HCI_READ_REMOTE_EXT_FEATURES_CFM        = HCI_READ_REMOTE_EXT_FEATURES,
    ENUM_DM_HCI_READ_REMOTE_VER_INFO_CFM            = HCI_READ_REMOTE_VER_INFO,
    ENUM_DM_HCI_READ_CLOCK_OFFSET_CFM               = HCI_READ_CLOCK_OFFSET,
    ENUM_DM_HCI_READ_LMP_HANDLE_CFM                 = HCI_READ_LMP_HANDLE               | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_TRUNCATED_PAGE_CFM                  = HCI_TRUNCATED_PAGE                | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_TRUNCATED_PAGE_CANCEL_CFM           = HCI_TRUNCATED_PAGE_CANCEL         | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_SET_CSB_RECEIVE_CFM                 = HCI_SET_CSB_RECEIVE               | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_SET_CSB_CFM                         = HCI_SET_CSB                       | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_START_SYNCHRONIZATION_TRAIN_CFM     = HCI_START_SYNCHRONIZATION_TRAIN   | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_RECEIVE_SYNCHRONIZATION_TRAIN_CFM   = HCI_RECEIVE_SYNCHRONIZATION_TRAIN | DM_HCI_WITH_HANDLE,

    /******************************************************************************
      Link Policy
      *****************************************************************************/
    /*-------------------------------------------------------------
      Downstream primitives
      ---------------------------------------------------------------*/
    ENUM_DM_HCI_HOLD_MODE_REQ                           = HCI_HOLD_MODE                             | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_QOS_SETUP_REQ                           = HCI_QOS_SETUP                             | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ROLE_DISCOVERY_REQ                      = HCI_ROLE_DISCOVERY                        | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_LINK_POLICY_SETTINGS_REQ           = HCI_READ_LINK_POLICY_SETTINGS             | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_DEFAULT_LINK_POLICY_SETTINGS_REQ   = HCI_READ_DEFAULT_LINK_POLICY_SETTINGS,
    ENUM_DM_HCI_WRITE_DEFAULT_LINK_POLICY_SETTINGS_REQ  = HCI_WRITE_DEFAULT_LINK_POLICY_SETTINGS,
    ENUM_DM_HCI_FLOW_SPEC_REQ                           = HCI_FLOW_SPEC                             | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_SNIFF_SUB_RATE_REQ                      = HCI_SNIFF_SUB_RATE                        | DM_HCI_WITH_HANDLE,

    /*-------------------------------------------------------------
      Upstream primitives
      ---------------------------------------------------------------*/
    ENUM_DM_HCI_QOS_SETUP_CFM                           = HCI_QOS_SETUP,
    ENUM_DM_HCI_ROLE_DISCOVERY_CFM                      = HCI_ROLE_DISCOVERY,
    ENUM_DM_HCI_READ_LINK_POLICY_SETTINGS_CFM           = HCI_READ_LINK_POLICY_SETTINGS,
    ENUM_DM_HCI_WRITE_LINK_POLICY_SETTINGS_CFM          = HCI_WRITE_LINK_POLICY_SETTINGS,
    ENUM_DM_HCI_READ_DEFAULT_LINK_POLICY_SETTINGS_CFM   = HCI_READ_DEFAULT_LINK_POLICY_SETTINGS     | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_DEFAULT_LINK_POLICY_SETTINGS_CFM  = HCI_WRITE_DEFAULT_LINK_POLICY_SETTINGS    | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_FLOW_SPEC_CFM                           = HCI_FLOW_SPEC,
    ENUM_DM_HCI_SNIFF_SUB_RATE_CFM                      = HCI_SNIFF_SUB_RATE,

    /******************************************************************************
      Host Controller and Baseband
      *****************************************************************************/
    /*-------------------------------------------------------------
      Downstream primitives
      ---------------------------------------------------------------*/
    ENUM_DM_HCI_SET_EVENT_MASK_REQ                          = HCI_SET_EVENT_MASK,
    ENUM_DM_HCI_RESET_REQ                                   = HCI_RESET,
    ENUM_DM_HCI_SET_EVENT_FILTER_REQ                        = HCI_SET_EVENT_FILTER,
    ENUM_DM_HCI_FLUSH_REQ                                   = HCI_FLUSH                         | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_PIN_TYPE_REQ                           = HCI_READ_PIN_TYPE,
    ENUM_DM_HCI_WRITE_PIN_TYPE_REQ                          = HCI_WRITE_PIN_TYPE,
    ENUM_DM_HCI_READ_STORED_LINK_KEY_REQ                    = HCI_READ_STORED_LINK_KEY,
    ENUM_DM_HCI_WRITE_STORED_LINK_KEY_REQ                   = HCI_WRITE_STORED_LINK_KEY,
    ENUM_DM_HCI_DELETE_STORED_LINK_KEY_REQ                  = HCI_DELETE_STORED_LINK_KEY,
    ENUM_DM_HCI_CHANGE_LOCAL_NAME_REQ                       = HCI_CHANGE_LOCAL_NAME,
    ENUM_DM_HCI_READ_LOCAL_NAME_REQ                         = HCI_READ_LOCAL_NAME,
    ENUM_DM_HCI_READ_CONN_ACCEPT_TIMEOUT_REQ                = HCI_READ_CONN_ACCEPT_TIMEOUT,
    ENUM_DM_HCI_WRITE_CONN_ACCEPT_TIMEOUT_REQ               = HCI_WRITE_CONN_ACCEPT_TIMEOUT,
    ENUM_DM_HCI_READ_PAGE_TIMEOUT_REQ                       = HCI_READ_PAGE_TIMEOUT,
    ENUM_DM_HCI_WRITE_PAGE_TIMEOUT_REQ                      = HCI_WRITE_PAGE_TIMEOUT,
    ENUM_DM_HCI_READ_SCAN_ENABLE_REQ                        = HCI_READ_SCAN_ENABLE,
    ENUM_DM_HCI_READ_PAGESCAN_ACTIVITY_REQ                  = HCI_READ_PAGESCAN_ACTIVITY,
    ENUM_DM_HCI_WRITE_PAGESCAN_ACTIVITY_REQ                 = HCI_WRITE_PAGESCAN_ACTIVITY,
    ENUM_DM_HCI_READ_INQUIRYSCAN_ACTIVITY_REQ               = HCI_READ_INQUIRYSCAN_ACTIVITY,
    ENUM_DM_HCI_WRITE_INQUIRYSCAN_ACTIVITY_REQ              = HCI_WRITE_INQUIRYSCAN_ACTIVITY,
    ENUM_DM_HCI_READ_AUTH_ENABLE_REQ                        = HCI_READ_AUTH_ENABLE,
    ENUM_DM_HCI_READ_ENC_MODE_REQ                           = HCI_READ_ENC_MODE,
    ENUM_DM_HCI_READ_CLASS_OF_DEVICE_REQ                    = HCI_READ_CLASS_OF_DEVICE,
    ENUM_DM_HCI_WRITE_CLASS_OF_DEVICE_REQ                   = HCI_WRITE_CLASS_OF_DEVICE,
    ENUM_DM_HCI_READ_VOICE_SETTING_REQ                      = HCI_READ_VOICE_SETTING,
    ENUM_DM_HCI_WRITE_VOICE_SETTING_REQ                     = HCI_WRITE_VOICE_SETTING,
    ENUM_DM_HCI_READ_AUTO_FLUSH_TIMEOUT_REQ                 = HCI_READ_AUTO_FLUSH_TIMEOUT       | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_AUTO_FLUSH_TIMEOUT_REQ                = HCI_WRITE_AUTO_FLUSH_TIMEOUT      | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_NUM_BCAST_RETXS_REQ                    = HCI_READ_NUM_BCAST_RETXS,
    ENUM_DM_HCI_WRITE_NUM_BCAST_RETXS_REQ                   = HCI_WRITE_NUM_BCAST_RETXS,
    ENUM_DM_HCI_READ_HOLD_MODE_ACTIVITY_REQ                 = HCI_READ_HOLD_MODE_ACTIVITY,
    ENUM_DM_HCI_WRITE_HOLD_MODE_ACTIVITY_REQ                = HCI_WRITE_HOLD_MODE_ACTIVITY,
    ENUM_DM_HCI_READ_TX_POWER_LEVEL_REQ                     = HCI_READ_TX_POWER_LEVEL           | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_SCO_FLOW_CON_ENABLE_REQ                = HCI_READ_SCO_FLOW_CON_ENABLE,
    ENUM_DM_HCI_WRITE_SCO_FLOW_CON_ENABLE_REQ               = HCI_WRITE_SCO_FLOW_CON_ENABLE,
    ENUM_DM_HCI_HOST_NUM_COMPLETED_PACKETS_REQ              = HCI_HOST_NUM_COMPLETED_PACKETS,
    ENUM_DM_HCI_READ_LINK_SUPERV_TIMEOUT_REQ                = HCI_READ_LINK_SUPERV_TIMEOUT      | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_LINK_SUPERV_TIMEOUT_REQ               = HCI_WRITE_LINK_SUPERV_TIMEOUT     | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_NUM_SUPPORTED_IAC_REQ                  = HCI_READ_NUM_SUPPORTED_IAC,
    ENUM_DM_HCI_READ_CURRENT_IAC_LAP_REQ                    = HCI_READ_CURRENT_IAC_LAP,
    ENUM_DM_HCI_WRITE_CURRENT_IAC_LAP_REQ                   = HCI_WRITE_CURRENT_IAC_LAP,
    ENUM_DM_HCI_READ_PAGESCAN_PERIOD_MODE_REQ               = HCI_READ_PAGESCAN_PERIOD_MODE,
    ENUM_DM_HCI_WRITE_PAGESCAN_PERIOD_MODE_REQ              = HCI_WRITE_PAGESCAN_PERIOD_MODE,
    ENUM_DM_HCI_READ_PAGESCAN_MODE_REQ                      = HCI_READ_PAGESCAN_MODE,
    ENUM_DM_HCI_WRITE_PAGESCAN_MODE_REQ                     = HCI_WRITE_PAGESCAN_MODE,
    ENUM_DM_HCI_SET_AFH_CHANNEL_CLASS_REQ                   = HCI_SET_AFH_CHANNEL_CLASS,
    ENUM_DM_HCI_READ_INQUIRY_SCAN_TYPE_REQ                  = HCI_READ_INQUIRY_SCAN_TYPE,
    ENUM_DM_HCI_WRITE_INQUIRY_SCAN_TYPE_REQ                 = HCI_WRITE_INQUIRY_SCAN_TYPE,
    ENUM_DM_HCI_READ_INQUIRY_MODE_REQ                       = HCI_READ_INQUIRY_MODE,
    ENUM_DM_HCI_WRITE_INQUIRY_MODE_REQ                      = HCI_WRITE_INQUIRY_MODE,
    ENUM_DM_HCI_READ_PAGE_SCAN_TYPE_REQ                     = HCI_READ_PAGE_SCAN_TYPE,
    ENUM_DM_HCI_WRITE_PAGE_SCAN_TYPE_REQ                    = HCI_WRITE_PAGE_SCAN_TYPE,
    ENUM_DM_HCI_READ_AFH_CHANNEL_CLASS_M_REQ                = HCI_READ_AFH_CHANNEL_CLASS_M,
    ENUM_DM_HCI_WRITE_AFH_CHANNEL_CLASS_M_REQ               = HCI_WRITE_AFH_CHANNEL_CLASS_M,
    ENUM_DM_HCI_READ_EXTENDED_INQUIRY_RESPONSE_DATA_REQ     = HCI_READ_EXTENDED_INQUIRY_RESPONSE_DATA,
    ENUM_DM_HCI_WRITE_EXTENDED_INQUIRY_RESPONSE_DATA_REQ    = HCI_WRITE_EXTENDED_INQUIRY_RESPONSE_DATA,
    ENUM_DM_HCI_REFRESH_ENCRYPTION_KEY_REQ                  = HCI_REFRESH_ENCRYPTION_KEY                | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_INQUIRY_RESPONSE_TX_POWER_LEVEL_REQ    = HCI_READ_INQUIRY_RESPONSE_TX_POWER_LEVEL,
    ENUM_DM_HCI_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_REQ      = HCI_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL,
    ENUM_DM_HCI_ENHANCED_FLUSH_REQ                          = HCI_ENHANCED_FLUSH                        | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_SECURE_CONNECTIONS_HOST_SUPPORT_REQ    = HCI_READ_SECURE_CONNECTIONS_HOST_SUPPORT,
    ENUM_DM_HCI_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT_REQ   = HCI_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT,
    ENUM_DM_HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_REQ      = HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT    | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_SET_RESERVED_LT_ADDR_REQ                    = HCI_SET_RESERVED_LT_ADDR,
    ENUM_DM_HCI_DELETE_RESERVED_LT_ADDR_REQ                 = HCI_DELETE_RESERVED_LT_ADDR,
    ENUM_DM_HCI_SET_CSB_DATA_REQ                            = HCI_SET_CSB_DATA,
    ENUM_DM_HCI_WRITE_SYNCHRONIZATION_TRAIN_PARAMS_REQ      = HCI_WRITE_SYNCHRONIZATION_TRAIN_PARAMS,
    ENUM_DM_HCI_READ_SYNCHRONIZATION_TRAIN_PARAMS_REQ       = HCI_READ_SYNCHRONIZATION_TRAIN_PARAMS,
    ENUM_DM_HCI_CONFIGURE_DATA_PATH_REQ                     = HCI_CONFIGURE_DATA_PATH,
    /*-------------------------------------------------------------
      Upstream primitives
      ---------------------------------------------------------------*/
    ENUM_DM_HCI_SET_EVENT_MASK_CFM                          = HCI_SET_EVENT_MASK                | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_RESET_CFM                                   = HCI_RESET                         | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_SET_EVENT_FILTER_CFM                        = HCI_SET_EVENT_FILTER              | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_FLUSH_CFM                                   = HCI_FLUSH,
    ENUM_DM_HCI_READ_PIN_TYPE_CFM                           = HCI_READ_PIN_TYPE                 | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_PIN_TYPE_CFM                          = HCI_WRITE_PIN_TYPE                | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_STORED_LINK_KEY_CFM                    = HCI_READ_STORED_LINK_KEY          | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_STORED_LINK_KEY_CFM                   = HCI_WRITE_STORED_LINK_KEY         | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_DELETE_STORED_LINK_KEY_CFM                  = HCI_DELETE_STORED_LINK_KEY        | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_CHANGE_LOCAL_NAME_CFM                       = HCI_CHANGE_LOCAL_NAME             | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_LOCAL_NAME_CFM                         = HCI_READ_LOCAL_NAME               | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_CONN_ACCEPT_TIMEOUT_CFM                = HCI_READ_CONN_ACCEPT_TIMEOUT      | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_CONN_ACCEPT_TIMEOUT_CFM               = HCI_WRITE_CONN_ACCEPT_TIMEOUT     | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_PAGE_TIMEOUT_CFM                       = HCI_READ_PAGE_TIMEOUT             | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_PAGE_TIMEOUT_CFM                      = HCI_WRITE_PAGE_TIMEOUT            | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_SCAN_ENABLE_CFM                        = HCI_READ_SCAN_ENABLE              | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_SCAN_ENABLE_CFM                       = HCI_WRITE_SCAN_ENABLE             | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_PAGESCAN_ACTIVITY_CFM                  = HCI_READ_PAGESCAN_ACTIVITY        | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_PAGESCAN_ACTIVITY_CFM                 = HCI_WRITE_PAGESCAN_ACTIVITY       | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_INQUIRYSCAN_ACTIVITY_CFM               = HCI_READ_INQUIRYSCAN_ACTIVITY     | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_INQUIRYSCAN_ACTIVITY_CFM              = HCI_WRITE_INQUIRYSCAN_ACTIVITY    | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_AUTH_ENABLE_CFM                        = HCI_READ_AUTH_ENABLE              | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_ENC_MODE_CFM                           = HCI_READ_ENC_MODE                 | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_CLASS_OF_DEVICE_CFM                    = HCI_READ_CLASS_OF_DEVICE          | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_CLASS_OF_DEVICE_CFM                   = HCI_WRITE_CLASS_OF_DEVICE         | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_VOICE_SETTING_CFM                      = HCI_READ_VOICE_SETTING            | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_VOICE_SETTING_CFM                     = HCI_WRITE_VOICE_SETTING           | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_AUTO_FLUSH_TIMEOUT_CFM                 = HCI_READ_AUTO_FLUSH_TIMEOUT,
    ENUM_DM_HCI_WRITE_AUTO_FLUSH_TIMEOUT_CFM                = HCI_WRITE_AUTO_FLUSH_TIMEOUT,
    ENUM_DM_HCI_READ_NUM_BCAST_RETXS_CFM                    = HCI_READ_NUM_BCAST_RETXS          | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_NUM_BCAST_RETXS_CFM                   = HCI_WRITE_NUM_BCAST_RETXS         | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_HOLD_MODE_ACTIVITY_CFM                 = HCI_READ_HOLD_MODE_ACTIVITY       | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_HOLD_MODE_ACTIVITY_CFM                = HCI_WRITE_HOLD_MODE_ACTIVITY      | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_TX_POWER_LEVEL_CFM                     = HCI_READ_TX_POWER_LEVEL,
    ENUM_DM_HCI_READ_SCO_FLOW_CON_ENABLE_CFM                = HCI_READ_SCO_FLOW_CON_ENABLE      | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_SCO_FLOW_CON_ENABLE_CFM               = HCI_WRITE_SCO_FLOW_CON_ENABLE     | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_LINK_SUPERV_TIMEOUT_CFM                = HCI_READ_LINK_SUPERV_TIMEOUT,
    ENUM_DM_HCI_WRITE_LINK_SUPERV_TIMEOUT_CFM               = HCI_WRITE_LINK_SUPERV_TIMEOUT,
    ENUM_DM_HCI_READ_NUM_SUPPORTED_IAC_CFM                  = HCI_READ_NUM_SUPPORTED_IAC        | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_CURRENT_IAC_LAP_CFM                    = HCI_READ_CURRENT_IAC_LAP          | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_CURRENT_IAC_LAP_CFM                   = HCI_WRITE_CURRENT_IAC_LAP         | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_PAGESCAN_PERIOD_MODE_CFM               = HCI_READ_PAGESCAN_PERIOD_MODE     | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_PAGESCAN_PERIOD_MODE_CFM              = HCI_WRITE_PAGESCAN_PERIOD_MODE    | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_PAGESCAN_MODE_CFM                      = HCI_READ_PAGESCAN_MODE            | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_PAGESCAN_MODE_CFM                     = HCI_WRITE_PAGESCAN_MODE           | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_SET_AFH_CHANNEL_CLASS_CFM                   = HCI_SET_AFH_CHANNEL_CLASS         | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_INQUIRY_SCAN_TYPE_CFM                  = HCI_READ_INQUIRY_SCAN_TYPE        | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_INQUIRY_SCAN_TYPE_CFM                 = HCI_WRITE_INQUIRY_SCAN_TYPE       | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_INQUIRY_MODE_CFM                       = HCI_READ_INQUIRY_MODE             | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_INQUIRY_MODE_CFM                      = HCI_WRITE_INQUIRY_MODE            | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_PAGE_SCAN_TYPE_CFM                     = HCI_READ_PAGE_SCAN_TYPE           | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_PAGE_SCAN_TYPE_CFM                    = HCI_WRITE_PAGE_SCAN_TYPE          | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_AFH_CHANNEL_CLASS_M_CFM                = HCI_READ_AFH_CHANNEL_CLASS_M      | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_AFH_CHANNEL_CLASS_M_CFM               = HCI_WRITE_AFH_CHANNEL_CLASS_M     | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_EXTENDED_INQUIRY_RESPONSE_DATA_CFM     = HCI_READ_EXTENDED_INQUIRY_RESPONSE_DATA  | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_EXTENDED_INQUIRY_RESPONSE_DATA_CFM    = HCI_WRITE_EXTENDED_INQUIRY_RESPONSE_DATA | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_REFRESH_ENCRYPTION_KEY_IND                  = HCI_REFRESH_ENCRYPTION_KEY,
    ENUM_DM_HCI_READ_INQUIRY_RESPONSE_TX_POWER_LEVEL_CFM    = HCI_READ_INQUIRY_RESPONSE_TX_POWER_LEVEL | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_CFM      = HCI_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL   | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ENHANCED_FLUSH_CFM                          = HCI_ENHANCED_FLUSH,
    ENUM_DM_HCI_READ_SECURE_CONNECTIONS_HOST_SUPPORT_CFM    = HCI_READ_SECURE_CONNECTIONS_HOST_SUPPORT | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT_CFM   = HCI_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_CFM      = HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT,
    ENUM_DM_HCI_SET_RESERVED_LT_ADDR_CFM                    = HCI_SET_RESERVED_LT_ADDR                 | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_DELETE_RESERVED_LT_ADDR_CFM                 = HCI_DELETE_RESERVED_LT_ADDR              | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_SET_CSB_DATA_CFM                            = HCI_SET_CSB_DATA                         | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_WRITE_SYNCHRONIZATION_TRAIN_PARAMS_CFM      = HCI_WRITE_SYNCHRONIZATION_TRAIN_PARAMS   | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_SYNCHRONIZATION_TRAIN_PARAMS_CFM       = HCI_READ_SYNCHRONIZATION_TRAIN_PARAMS    | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_CONFIGURE_DATA_PATH_CFM                     = HCI_CONFIGURE_DATA_PATH | DM_HCI_WITH_HANDLE,

    /******************************************************************************
      Informational parameters
      *****************************************************************************/
    /*-------------------------------------------------------------
      Downstream primitives
      ---------------------------------------------------------------*/
    ENUM_DM_HCI_READ_LOCAL_VER_INFO_REQ         = HCI_READ_LOCAL_VER_INFO,
    ENUM_DM_HCI_READ_LOCAL_SUPP_FEATURES_REQ    = HCI_READ_LOCAL_SUPP_FEATURES,
    ENUM_DM_HCI_READ_LOCAL_EXT_FEATURES_REQ     = HCI_READ_LOCAL_EXT_FEATURES,
    ENUM_DM_HCI_READ_COUNTRY_CODE_REQ           = HCI_READ_COUNTRY_CODE,
    ENUM_DM_HCI_READ_BD_ADDR_REQ                = HCI_READ_BD_ADDR,

    /*-------------------------------------------------------------
      Upstream primitives
      ---------------------------------------------------------------*/
    ENUM_DM_HCI_READ_LOCAL_VER_INFO_CFM        = HCI_READ_LOCAL_VER_INFO       | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_LOCAL_SUPP_FEATURES_CFM   = HCI_READ_LOCAL_SUPP_FEATURES  | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_LOCAL_EXT_FEATURES_CFM    = HCI_READ_LOCAL_EXT_FEATURES   | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_COUNTRY_CODE_CFM          = HCI_READ_COUNTRY_CODE         | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_BD_ADDR_CFM               = HCI_READ_BD_ADDR              | DM_HCI_WITH_HANDLE,

    /******************************************************************************
      Status parameters
      *****************************************************************************/
    /*-------------------------------------------------------------
      Downstream primitives
      ---------------------------------------------------------------*/
    ENUM_DM_HCI_READ_FAILED_CONTACT_COUNT_REQ   = HCI_READ_FAILED_CONTACT_COUNT     | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_RESET_FAILED_CONTACT_COUNT_REQ  = HCI_RESET_FAILED_CONTACT_COUNT    | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_GET_LINK_QUALITY_REQ            = HCI_GET_LINK_QUALITY              | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_RSSI_REQ                   = HCI_READ_RSSI                     | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_AFH_CHANNEL_MAP_REQ        = HCI_READ_AFH_CHANNEL_MAP          | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_CLOCK_REQ                  = HCI_READ_CLOCK                    | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_READ_ENCRYPTION_KEY_SIZE_REQ    = HCI_READ_ENCRYPTION_KEY_SIZE      | DM_HCI_WITH_HANDLE,

    /*-------------------------------------------------------------
      Upstream primitives
      ---------------------------------------------------------------*/
    ENUM_DM_HCI_READ_FAILED_CONTACT_COUNT_CFM   = HCI_READ_FAILED_CONTACT_COUNT,
    ENUM_DM_HCI_RESET_FAILED_CONTACT_COUNT_CFM  = HCI_RESET_FAILED_CONTACT_COUNT,
    ENUM_DM_HCI_GET_LINK_QUALITY_CFM            = HCI_GET_LINK_QUALITY,
    ENUM_DM_HCI_READ_RSSI_CFM                   = HCI_READ_RSSI,
    ENUM_DM_HCI_READ_AFH_CHANNEL_MAP_CFM        = HCI_READ_AFH_CHANNEL_MAP,
    ENUM_DM_HCI_READ_CLOCK_CFM                  = HCI_READ_CLOCK,
    ENUM_DM_HCI_READ_ENCRYPTION_KEY_SIZE_CFM    = HCI_READ_ENCRYPTION_KEY_SIZE,

    /************************************************************************
      Testing primitives
      ***********************************************************************/
    /*-------------------------------------------------------------
      Downstream primitives
      ---------------------------------------------------------------*/
    ENUM_DM_HCI_ENABLE_DUT_MODE_REQ = HCI_ENABLE_DUT_MODE,

    /*-------------------------------------------------------------
      Upstream primitives
      ---------------------------------------------------------------*/
    ENUM_DM_HCI_ENABLE_DUT_MODE_CFM = HCI_ENABLE_DUT_MODE | DM_HCI_WITH_HANDLE,

    /************************************************************************
      ULP primitives
      ***********************************************************************/
    /*-------------------------------------------------------------
      Downstream primitives
      ---------------------------------------------------------------*/
    ENUM_DM_HCI_ULP_SET_EVENT_MASK_REQ                      = HCI_ULP_SET_EVENT_MASK,
    ENUM_DM_HCI_ULP_READ_LOCAL_SUPPORTED_FEATURES_REQ       = HCI_ULP_READ_LOCAL_SUPPORTED_FEATURES,
    /* ENUM_DM_HCI_ULP_SET_ADVERTISING_PARAMETERS_REQ is part of DM_PRIV_PRIM  */
    ENUM_DM_HCI_ULP_READ_ADVERTISING_CHANNEL_TX_POWER_REQ   = HCI_ULP_READ_ADVERTISING_CHANNEL_TX_POWER,
    ENUM_DM_HCI_ULP_SET_ADVERTISING_DATA_REQ                = HCI_ULP_SET_ADVERTISING_DATA,
    ENUM_DM_HCI_ULP_SET_SCAN_RESPONSE_DATA_REQ              = HCI_ULP_SET_SCAN_RESPONSE_DATA,
    /* ENUM_DM_HCI_ULP_SET_ADVERTISE_ENABLE_REQ is part of DM_PRIV_PRIM */
    /* ENUM_DM_HCI_ULP_SET_SCAN_PARAMETERS_REQ is part of DM_PRIV_PRIM */
    /* ENUM_DM_HCI_ULP_SET_SCAN_ENABLE_REQ is part of DM_PRIV_PRIM */
    ENUM_DM_HCI_ULP_CREATE_CONNECTION_CANCEL_REQ            = HCI_ULP_CREATE_CONNECTION_CANCEL,
    ENUM_DM_HCI_ULP_READ_WHITE_LIST_SIZE_REQ                = HCI_ULP_READ_WHITE_LIST_SIZE,
    ENUM_DM_HCI_ULP_CLEAR_WHITE_LIST_REQ                    = HCI_ULP_CLEAR_WHITE_LIST,
    ENUM_DM_HCI_ULP_ADD_DEVICE_TO_WHITE_LIST_REQ            = HCI_ULP_ADD_DEVICE_TO_WHITE_LIST,
    ENUM_DM_HCI_ULP_REMOVE_DEVICE_FROM_WHITE_LIST_REQ       = HCI_ULP_REMOVE_DEVICE_FROM_WHITE_LIST,
    ENUM_DM_HCI_ULP_SET_HOST_CHANNEL_CLASSIFICATION_REQ     = HCI_ULP_SET_HOST_CHANNEL_CLASSIFICATION,
    ENUM_DM_HCI_ULP_READ_CHANNEL_MAP_REQ                    = HCI_ULP_READ_CHANNEL_MAP                      | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_READ_REMOTE_USED_FEATURES_REQ           = HCI_ULP_READ_REMOTE_USED_FEATURES             | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_ENCRYPT_REQ                             = HCI_ULP_ENCRYPT,
    ENUM_DM_HCI_ULP_RAND_REQ                                = HCI_ULP_RAND,
    ENUM_DM_HCI_ULP_READ_SUPPORTED_STATES_REQ               = HCI_ULP_READ_SUPPORTED_STATES,
    ENUM_DM_HCI_ULP_RECEIVER_TEST_REQ                       = HCI_ULP_RECEIVER_TEST,
    ENUM_DM_HCI_ULP_TRANSMITTER_TEST_REQ                    = HCI_ULP_TRANSMITTER_TEST,
    ENUM_DM_HCI_ULP_TEST_END_REQ                            = HCI_ULP_TEST_END,
    ENUM_DM_HCI_ULP_READ_RESOLVING_LIST_SIZE_REQ            = HCI_ULP_READ_RESOLVING_LIST_SIZE,
    ENUM_DM_HCI_ULP_SET_PRIVACY_MODE_REQ                    = HCI_ULP_SET_PRIVACY_MODE,
    ENUM_DM_HCI_ULP_ENHANCED_RECEIVER_TEST_REQ              = HCI_ULP_ENHANCED_RECEIVER_TEST,
    ENUM_DM_HCI_ULP_ENHANCED_TRANSMITTER_TEST_REQ           = HCI_ULP_ENHANCED_TRANSMITTER_TEST,
    ENUM_DM_HCI_ULP_EXT_ADV_SET_DATA_REQ                    = HCI_ULP_EXT_ADV_SET_DATA,
    ENUM_DM_HCI_ULP_EXT_ADV_SET_SCAN_RESP_DATA_REQ          = HCI_ULP_EXT_ADV_SET_SCAN_RESP_DATA,
    ENUM_DM_HCI_ULP_PERIODIC_ADV_SET_DATA_REQ               = HCI_ULP_PERIODIC_ADV_SET_DATA,

    /*-------------------------------------------------------------
      Upstream primitives
      ---------------------------------------------------------------*/
    ENUM_DM_HCI_ULP_SET_EVENT_MASK_CFM                      = HCI_ULP_SET_EVENT_MASK                        | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_READ_LOCAL_SUPPORTED_FEATURES_CFM       = HCI_ULP_READ_LOCAL_SUPPORTED_FEATURES         | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_SET_ADVERTISING_PARAMETERS_CFM          = HCI_ULP_SET_ADVERTISING_PARAMETERS            | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_READ_ADVERTISING_CHANNEL_TX_POWER_CFM   = HCI_ULP_READ_ADVERTISING_CHANNEL_TX_POWER     | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_SET_ADVERTISING_DATA_CFM                = HCI_ULP_SET_ADVERTISING_DATA                  | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_SET_SCAN_RESPONSE_DATA_CFM              = HCI_ULP_SET_SCAN_RESPONSE_DATA                | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_SET_ADVERTISE_ENABLE_CFM                = HCI_ULP_SET_ADVERTISE_ENABLE                  | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_SET_SCAN_PARAMETERS_CFM                 = HCI_ULP_SET_SCAN_PARAMETERS                   | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_SET_SCAN_ENABLE_CFM                     = HCI_ULP_SET_SCAN_ENABLE                       | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_CREATE_CONNECTION_CANCEL_CFM            = HCI_ULP_CREATE_CONNECTION_CANCEL              | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_READ_WHITE_LIST_SIZE_CFM                = HCI_ULP_READ_WHITE_LIST_SIZE                  | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_CLEAR_WHITE_LIST_CFM                    = HCI_ULP_CLEAR_WHITE_LIST                      | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_ADD_DEVICE_TO_WHITE_LIST_CFM            = HCI_ULP_ADD_DEVICE_TO_WHITE_LIST              | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_REMOVE_DEVICE_FROM_WHITE_LIST_CFM       = HCI_ULP_REMOVE_DEVICE_FROM_WHITE_LIST         | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_CONNECTION_UPDATE_COMPLETE_IND          = HCI_ULP_CONNECTION_UPDATE                     ,
    ENUM_DM_HCI_ULP_SET_HOST_CHANNEL_CLASSIFICATION_CFM     = HCI_ULP_SET_HOST_CHANNEL_CLASSIFICATION       | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_READ_CHANNEL_MAP_CFM                    = HCI_ULP_READ_CHANNEL_MAP                      ,
    ENUM_DM_HCI_ULP_READ_REMOTE_USED_FEATURES_CFM           = HCI_ULP_READ_REMOTE_USED_FEATURES             ,
    ENUM_DM_HCI_ULP_ENCRYPT_CFM                             = HCI_ULP_ENCRYPT                               | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_RAND_CFM                                = HCI_ULP_RAND                                  | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_READ_SUPPORTED_STATES_CFM               = HCI_ULP_READ_SUPPORTED_STATES                 | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_RECEIVER_TEST_CFM                       = HCI_ULP_RECEIVER_TEST                         | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_TRANSMITTER_TEST_CFM                    = HCI_ULP_TRANSMITTER_TEST                      | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_TEST_END_CFM                            = HCI_ULP_TEST_END                              | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_READ_RESOLVING_LIST_SIZE_CFM            = HCI_ULP_READ_RESOLVING_LIST_SIZE              | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_SET_PRIVACY_MODE_CFM                    = HCI_ULP_SET_PRIVACY_MODE                      | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_ENHANCED_RECEIVER_TEST_CFM              = HCI_ULP_ENHANCED_RECEIVER_TEST                | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_ENHANCED_TRANSMITTER_TEST_CFM           = HCI_ULP_ENHANCED_TRANSMITTER_TEST             | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_EXT_ADV_SET_DATA_CFM                    = HCI_ULP_EXT_ADV_SET_DATA                      | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_EXT_ADV_SET_SCAN_RESP_DATA_CFM          = HCI_ULP_EXT_ADV_SET_SCAN_RESP_DATA            | DM_HCI_WITH_HANDLE,
    ENUM_DM_HCI_ULP_PERIODIC_ADV_SET_DATA_CFM               = HCI_ULP_PERIODIC_ADV_SET_DATA                 | DM_HCI_WITH_HANDLE
} DM_PRIM_T;

/* ... and then reflect it here */
#define DM_AM_REGISTER_REQ                                  ((dm_prim_t)ENUM_DM_AM_REGISTER_REQ)
#define DM_AM_REGISTER_CFM                                  ((dm_prim_t)ENUM_DM_AM_REGISTER_CFM)
#define DM_SET_BT_VERSION_REQ                               ((dm_prim_t)ENUM_DM_SET_BT_VERSION_REQ)
#define DM_SET_BT_VERSION_CFM                               ((dm_prim_t)ENUM_DM_SET_BT_VERSION_CFM)
#define DM_AM_REGISTER_WRONG_API_REQ                        ((dm_prim_t)ENUM_DM_AM_REGISTER_WRONG_API_REQ)
#define DM_AM_REGISTER_WRONG_API_CFM                        ((dm_prim_t)ENUM_DM_AM_REGISTER_WRONG_API_CFM)
#define DM_BAD_MESSAGE_IND                                  ((dm_prim_t)ENUM_DM_BAD_MESSAGE_IND)
#define DM_SET_BLE_CONNECTION_PARAMETERS_REQ                ((dm_prim_t)ENUM_DM_SET_BLE_CONNECTION_PARAMETERS_REQ)
#define DM_SET_BLE_CONNECTION_PARAMETERS_CFM                ((dm_prim_t)ENUM_DM_SET_BLE_CONNECTION_PARAMETERS_CFM)
#define DM_BLE_UPDATE_CONNECTION_PARAMETERS_REQ             ((dm_prim_t)ENUM_DM_BLE_UPDATE_CONNECTION_PARAMETERS_REQ)
#define DM_BLE_UPDATE_CONNECTION_PARAMETERS_CFM             ((dm_prim_t)ENUM_DM_BLE_UPDATE_CONNECTION_PARAMETERS_CFM)
#define DM_BLE_ACCEPT_CONNECTION_PAR_UPDATE_IND             ((dm_prim_t)ENUM_DM_BLE_ACCEPT_CONNECTION_PAR_UPDATE_IND)
#define DM_BLE_ACCEPT_CONNECTION_PAR_UPDATE_RSP             ((dm_prim_t)ENUM_DM_BLE_ACCEPT_CONNECTION_PAR_UPDATE_RSP)
#define DM_HCI_CSB_TX_TIMEOUT_RSP                           ((dm_prim_t)ENUM_DM_HCI_CSB_TX_TIMEOUT_RSP)
#define DM_HCI_CSB_RX_TIMEOUT_RSP                           ((dm_prim_t)ENUM_DM_HCI_CSB_RX_TIMEOUT_RSP)
#define DM_CONTROLLER_READY_NTF                             ((dm_prim_t)ENUM_DM_CONTROLLER_READY_NTF)
#define DM_WRITE_SC_HOST_SUPPORT_OVERRIDE_REQ               ((dm_prim_t)ENUM_DM_WRITE_SC_HOST_SUPPORT_OVERRIDE_REQ)
#define DM_WRITE_SC_HOST_SUPPORT_OVERRIDE_CFM               ((dm_prim_t)ENUM_DM_WRITE_SC_HOST_SUPPORT_OVERRIDE_CFM)
#define DM_READ_SC_HOST_SUPPORT_OVERRIDE_MAX_BD_ADDR_REQ    ((dm_prim_t)ENUM_DM_READ_SC_HOST_SUPPORT_OVERRIDE_MAX_BD_ADDR_REQ)
#define DM_READ_SC_HOST_SUPPORT_OVERRIDE_MAX_BD_ADDR_CFM    ((dm_prim_t)ENUM_DM_READ_SC_HOST_SUPPORT_OVERRIDE_MAX_BD_ADDR_CFM)


/*-------------------------------------------------------------
  Synchronous Connection Interface Primitives
  ---------------------------------------------------------------*/
#define DM_SYNC_REGISTER_REQ            ((dm_prim_t)(ENUM_DM_SYNC_REGISTER_REQ))
#define DM_SYNC_REGISTER_CFM            ((dm_prim_t)(ENUM_DM_SYNC_REGISTER_CFM))
#define DM_SYNC_UNREGISTER_REQ          ((dm_prim_t)(ENUM_DM_SYNC_UNREGISTER_REQ))
#define DM_SYNC_UNREGISTER_CFM          ((dm_prim_t)(ENUM_DM_SYNC_UNREGISTER_CFM))
#define DM_SYNC_CONNECT_REQ             ((dm_prim_t)(ENUM_DM_SYNC_CONNECT_REQ))
#define DM_SYNC_CONNECT_CFM             ((dm_prim_t)(ENUM_DM_SYNC_CONNECT_CFM))
#define DM_SYNC_CONNECT_COMPLETE_IND    ((dm_prim_t)(ENUM_DM_SYNC_CONNECT_COMPLETE_IND))
#define DM_SYNC_CONNECT_IND             ((dm_prim_t)(ENUM_DM_SYNC_CONNECT_IND))
#define DM_SYNC_CONNECT_RSP             ((dm_prim_t)(ENUM_DM_SYNC_CONNECT_RSP))
#define DM_SYNC_RENEGOTIATE_REQ         ((dm_prim_t)(ENUM_DM_SYNC_RENEGOTIATE_REQ))
#define DM_SYNC_RENEGOTIATE_IND         ((dm_prim_t)(ENUM_DM_SYNC_RENEGOTIATE_IND))
#define DM_SYNC_RENEGOTIATE_CFM         ((dm_prim_t)(ENUM_DM_SYNC_RENEGOTIATE_CFM))
#define DM_SYNC_DISCONNECT_REQ          ((dm_prim_t)(ENUM_DM_SYNC_DISCONNECT_REQ))
#define DM_SYNC_DISCONNECT_IND          ((dm_prim_t)(ENUM_DM_SYNC_DISCONNECT_IND))
#define DM_SYNC_DISCONNECT_CFM          ((dm_prim_t)(ENUM_DM_SYNC_DISCONNECT_CFM))

/*-------------------------------------------------------------
  Security Management Primitives
  ---------------------------------------------------------------*/

#define DM_SM_REGISTER_REQ              ((dm_prim_t)(ENUM_DM_SM_REGISTER_REQ))
#define DM_SM_REGISTER_CFM              ((dm_prim_t)(ENUM_DM_SM_REGISTER_CFM))
#define DM_SM_UNREGISTER_REQ            ((dm_prim_t)(ENUM_DM_SM_UNREGISTER_REQ))
#define DM_SM_UNREGISTER_CFM            ((dm_prim_t)(ENUM_DM_SM_UNREGISTER_CFM))
#define DM_SM_REGISTER_OUTGOING_REQ     ((dm_prim_t)(ENUM_DM_SM_REGISTER_OUTGOING_REQ))
#define DM_SM_REGISTER_OUTGOING_CFM     ((dm_prim_t)(ENUM_DM_SM_REGISTER_OUTGOING_CFM))
#define DM_SM_UNREGISTER_OUTGOING_REQ   ((dm_prim_t)(ENUM_DM_SM_UNREGISTER_OUTGOING_REQ))
#define DM_SM_UNREGISTER_OUTGOING_CFM   ((dm_prim_t)(ENUM_DM_SM_UNREGISTER_OUTGOING_CFM))
#define DM_SM_ACCESS_REQ                ((dm_prim_t)(ENUM_DM_SM_ACCESS_REQ))
#define DM_SM_ACCESS_CFM                ((dm_prim_t)(ENUM_DM_SM_ACCESS_CFM))
#define DM_SM_ACCESS_IND                ((dm_prim_t)(ENUM_DM_SM_ACCESS_IND))
#define DM_SM_INIT_REQ                  ((dm_prim_t)(ENUM_DM_SM_INIT_REQ))
#define DM_SM_INIT_CFM                  ((dm_prim_t)(ENUM_DM_SM_INIT_CFM))
#define DM_SM_ADD_DEVICE_REQ            ((dm_prim_t)(ENUM_DM_SM_ADD_DEVICE_REQ))
#define DM_SM_ADD_DEVICE_CFM            ((dm_prim_t)(ENUM_DM_SM_ADD_DEVICE_CFM))
#define DM_SM_REMOVE_DEVICE_REQ         ((dm_prim_t)(ENUM_DM_SM_REMOVE_DEVICE_REQ))
#define DM_SM_REMOVE_DEVICE_CFM         ((dm_prim_t)(ENUM_DM_SM_REMOVE_DEVICE_CFM))
#define DM_SM_LINK_KEY_REQUEST_IND      ((dm_prim_t)(ENUM_DM_SM_LINK_KEY_REQUEST_IND))
#define DM_SM_LINK_KEY_REQUEST_RSP      ((dm_prim_t)(ENUM_DM_SM_LINK_KEY_REQUEST_RSP))
#define DM_SM_PIN_REQUEST_IND           ((dm_prim_t)(ENUM_DM_SM_PIN_REQUEST_IND))
#define DM_SM_PIN_REQUEST_RSP           ((dm_prim_t)(ENUM_DM_SM_PIN_REQUEST_RSP))
#define DM_SM_LINK_KEY_IND              ((dm_prim_t)(ENUM_DM_SM_LINK_KEY_IND))
#define DM_SM_AUTHORISE_IND             ((dm_prim_t)(ENUM_DM_SM_AUTHORISE_IND))
#define DM_SM_AUTHORISE_RSP             ((dm_prim_t)(ENUM_DM_SM_AUTHORISE_RSP))
#define DM_SM_AUTHENTICATE_REQ          ((dm_prim_t)(ENUM_DM_SM_AUTHENTICATE_REQ))
#define DM_SM_AUTHENTICATE_CFM          ((dm_prim_t)(ENUM_DM_SM_AUTHENTICATE_CFM))
#define DM_SM_ENCRYPT_REQ               ((dm_prim_t)(ENUM_DM_SM_ENCRYPT_REQ))
#define DM_SM_ENCRYPT_CFM               ((dm_prim_t)(ENUM_DM_SM_ENCRYPT_CFM))
#define DM_SM_ENCRYPTION_CHANGE_IND     ((dm_prim_t)(ENUM_DM_SM_ENCRYPTION_CHANGE_IND))
#define DM_SM_ENCRYPTION_CHANGE_KEY_SIZE_IND ((dm_prim_t)(ENUM_DM_SM_ENCRYPTION_CHANGE_KEY_SIZE_IND))
#define DM_SM_SERVICE_REGISTER_REQ      ((dm_prim_t)(ENUM_DM_SM_SERVICE_REGISTER_REQ))
#define DM_SM_SERVICE_REGISTER_OUTGOING_REQ  ((dm_prim_t)(ENUM_DM_SM_SERVICE_REGISTER_OUTGOING_REQ))


#define DM_SM_IO_CAPABILITY_RESPONSE_IND        \
                ((dm_prim_t)(ENUM_DM_SM_IO_CAPABILITY_RESPONSE_IND))
#define DM_SM_IO_CAPABILITY_REQUEST_IND         \
                ((dm_prim_t)(ENUM_DM_SM_IO_CAPABILITY_REQUEST_IND))
#define DM_SM_IO_CAPABILITY_REQUEST_RSP         \
                ((dm_prim_t)(ENUM_DM_SM_IO_CAPABILITY_REQUEST_RSP))
#define DM_SM_IO_CAPABILITY_REQUEST_NEG_RSP     \
                ((dm_prim_t)(ENUM_DM_SM_IO_CAPABILITY_REQUEST_NEG_RSP))
#define DM_SM_USER_CONFIRMATION_REQUEST_IND     \
                ((dm_prim_t)(ENUM_DM_SM_USER_CONFIRMATION_REQUEST_IND))
#define DM_SM_USER_CONFIRMATION_REQUEST_RSP     \
                ((dm_prim_t)(ENUM_DM_SM_USER_CONFIRMATION_REQUEST_RSP))
#define DM_SM_USER_CONFIRMATION_REQUEST_NEG_RSP \
                ((dm_prim_t)(ENUM_DM_SM_USER_CONFIRMATION_REQUEST_NEG_RSP))
#define DM_SM_USER_PASSKEY_REQUEST_IND          \
                ((dm_prim_t)(ENUM_DM_SM_USER_PASSKEY_REQUEST_IND))
#define DM_SM_USER_PASSKEY_REQUEST_RSP          \
                ((dm_prim_t)(ENUM_DM_SM_USER_PASSKEY_REQUEST_RSP))
#define DM_SM_USER_PASSKEY_REQUEST_NEG_RSP      \
                ((dm_prim_t)(ENUM_DM_SM_USER_PASSKEY_REQUEST_NEG_RSP))
#define DM_SM_SIMPLE_PAIRING_COMPLETE_IND       \
                ((dm_prim_t)(ENUM_DM_SM_SIMPLE_PAIRING_COMPLETE_IND))
#define DM_SM_READ_LOCAL_OOB_DATA_REQ           \
                ((dm_prim_t)(ENUM_DM_SM_READ_LOCAL_OOB_DATA_REQ))
#define DM_SM_READ_LOCAL_OOB_DATA_CFM           \
                ((dm_prim_t)(ENUM_DM_SM_READ_LOCAL_OOB_DATA_CFM))
#define DM_SM_USER_PASSKEY_NOTIFICATION_IND     \
                ((dm_prim_t)(ENUM_DM_SM_USER_PASSKEY_NOTIFICATION_IND))
#define DM_SM_SEND_KEYPRESS_NOTIFICATION_REQ    \
                ((dm_prim_t)(ENUM_DM_SM_SEND_KEYPRESS_NOTIFICATION_REQ))
#define DM_SM_KEYPRESS_NOTIFICATION_IND         \
                ((dm_prim_t)(ENUM_DM_SM_KEYPRESS_NOTIFICATION_IND))
#define DM_SM_BONDING_REQ           ((dm_prim_t)(ENUM_DM_SM_BONDING_REQ))
#define DM_SM_BONDING_CFM           ((dm_prim_t)(ENUM_DM_SM_BONDING_CFM))
#define DM_SM_BONDING_CANCEL_REQ    ((dm_prim_t)(ENUM_DM_SM_BONDING_CANCEL_REQ))
#define DM_SM_READ_DEVICE_REQ       ((dm_prim_t)(ENUM_DM_SM_READ_DEVICE_REQ))
#define DM_SM_READ_DEVICE_CFM       ((dm_prim_t)(ENUM_DM_SM_READ_DEVICE_CFM))
#define DM_SM_KEYS_IND              ((dm_prim_t)(ENUM_DM_SM_KEYS_IND))
#define DM_SM_SECURITY_REQ          ((dm_prim_t)(ENUM_DM_SM_SECURITY_REQ))
#define DM_SM_SECURITY_CFM          ((dm_prim_t)(ENUM_DM_SM_SECURITY_CFM))
#define DM_SM_SECURITY_IND          ((dm_prim_t)(ENUM_DM_SM_SECURITY_IND))
#define DM_SM_KEY_REQUEST_IND       ((dm_prim_t)(ENUM_DM_SM_KEY_REQUEST_IND))
#define DM_SM_KEY_REQUEST_RSP       ((dm_prim_t)(ENUM_DM_SM_KEY_REQUEST_RSP))
#define DM_SM_KEY_REQUEST_NEG_RSP   ((dm_prim_t)(ENUM_DM_SM_KEY_REQUEST_NEG_RSP))
#define DM_SM_DATA_SIGN_REQ         ((dm_prim_t)(ENUM_DM_SM_DATA_SIGN_REQ))
#define DM_SM_DATA_SIGN_CFM         ((dm_prim_t)(ENUM_DM_SM_DATA_SIGN_CFM))
#define DM_SM_CSRK_COUNTER_CHANGE_IND ((dm_prim_t)(ENUM_DM_SM_CSRK_COUNTER_CHANGE_IND))
#define DM_SM_GENERATE_LOCAL_KEY_REQ          ((dm_prim_t)(ENUM_DM_SM_GENERATE_LOCAL_KEY_REQ))
#define DM_SM_GENERATE_LOCAL_KEY_CFM            ((dm_prim_t)(ENUM_DM_SM_GENERATE_LOCAL_KEY_CFM))
#define DM_SM_GENERATE_LOCAL_KEY_IND            ((dm_prim_t)(ENUM_DM_SM_GENERATE_LOCAL_KEY_IND))
#define DM_SM_LOCAL_KEY_DELETED_IND            ((dm_prim_t)(ENUM_DM_SM_LOCAL_KEY_DELETED_IND))
#define DM_SM_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_REQ \
    ((dm_prim_t)(ENUM_DM_SM_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_REQ))
#define DM_SM_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_CFM \
    ((dm_prim_t)(ENUM_DM_SM_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_CFM))
#define DM_SM_AUTO_CONFIGURE_LOCAL_ADDRESS_REQ \
    ((dm_prim_t)(ENUM_DM_SM_AUTO_CONFIGURE_LOCAL_ADDRESS_REQ))
#define DM_SM_AUTO_CONFIGURE_LOCAL_ADDRESS_CFM \
    ((dm_prim_t)(ENUM_DM_SM_AUTO_CONFIGURE_LOCAL_ADDRESS_CFM))
#define DM_SM_READ_RANDOM_ADDRESS_REQ \
    ((dm_prim_t)(ENUM_DM_SM_READ_RANDOM_ADDRESS_REQ))
#define DM_SM_READ_RANDOM_ADDRESS_CFM \
    ((dm_prim_t)(ENUM_DM_SM_READ_RANDOM_ADDRESS_CFM))
#define DM_SM_READ_LOCAL_IRK_REQ \
    ((dm_prim_t)(ENUM_DM_SM_READ_LOCAL_IRK_REQ))
#define DM_SM_READ_LOCAL_IRK_CFM \
    ((dm_prim_t)(ENUM_DM_SM_READ_LOCAL_IRK_CFM))
#define DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_RSP \
    ((dm_prim_t)(ENUM_DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_RSP))
#define DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_IND \
    ((dm_prim_t)(ENUM_DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_IND))
#define DM_SM_SIRK_OPERATION_REQ \
    ((dm_prim_t)(ENUM_DM_SM_SIRK_OPERATION_REQ))
#define DM_SM_SIRK_OPERATION_CFM \
    ((dm_prim_t)(ENUM_DM_SM_SIRK_OPERATION_CFM))
#define DM_SM_CONFIG_REQ \
    ((dm_prim_t)(ENUM_DM_SM_CONFIG_REQ))
#define DM_SM_CONFIG_CFM \
    ((dm_prim_t)(ENUM_DM_SM_CONFIG_CFM))
#define DM_SM_ENCRYPT_DATA_REQ \
    ((dm_prim_t)(ENUM_DM_SM_ENCRYPT_DATA_REQ))
#define DM_SM_ENCRYPT_DATA_CFM \
    ((dm_prim_t)(ENUM_DM_SM_ENCRYPT_DATA_CFM))

/*-------------------------------------------------------------
  DM private primitives
  ---------------------------------------------------------------*/

#define DM_WRITE_CACHED_PAGE_MODE_REQ    ((dm_prim_t)(ENUM_DM_WRITE_CACHED_PAGE_MODE_REQ))
#define DM_WRITE_CACHED_PAGE_MODE_CFM    ((dm_prim_t)(ENUM_DM_WRITE_CACHED_PAGE_MODE_CFM))
#define DM_WRITE_CACHED_CLOCK_OFFSET_REQ ((dm_prim_t)(ENUM_DM_WRITE_CACHED_CLOCK_OFFSET_REQ))
#define DM_WRITE_CACHED_CLOCK_OFFSET_CFM ((dm_prim_t)(ENUM_DM_WRITE_CACHED_CLOCK_OFFSET_CFM))
#define DM_CLEAR_PARAM_CACHE_REQ         ((dm_prim_t)(ENUM_DM_CLEAR_PARAM_CACHE_REQ))
#define DM_CLEAR_PARAM_CACHE_CFM         ((dm_prim_t)(ENUM_DM_CLEAR_PARAM_CACHE_CFM))
#define DM_ACL_OPEN_REQ                  ((dm_prim_t)(ENUM_DM_ACL_OPEN_REQ))
#define DM_ACL_OPEN_CFM                  ((dm_prim_t)(ENUM_DM_ACL_OPEN_CFM))
#define DM_ACL_CLOSE_REQ                 ((dm_prim_t)(ENUM_DM_ACL_CLOSE_REQ))
#define DM_ACL_OPENED_IND                ((dm_prim_t)(ENUM_DM_ACL_OPENED_IND))
#define DM_ACL_CLOSED_IND                ((dm_prim_t)(ENUM_DM_ACL_CLOSED_IND))
#define DM_ACL_CLOSE_CFM                 ((dm_prim_t)(ENUM_DM_ACL_CLOSE_CFM))
#define DM_SET_DEFAULT_LINK_POLICY_REQ   ((dm_prim_t)(ENUM_DM_SET_DEFAULT_LINK_POLICY_REQ))

#define DM_LP_WRITE_POWERSTATES_REQ      ((dm_prim_t)(ENUM_DM_LP_WRITE_POWERSTATES_REQ))
#define DM_LP_WRITE_POWERSTATES_CFM      ((dm_prim_t)(ENUM_DM_LP_WRITE_POWERSTATES_CFM))
#define DM_LP_WRITE_ROLESWITCH_POLICY_REQ   ((dm_prim_t)(ENUM_DM_LP_WRITE_ROLESWITCH_POLICY_REQ))
#define DM_LP_WRITE_ROLESWITCH_POLICY_CFM   ((dm_prim_t)(ENUM_DM_LP_WRITE_ROLESWITCH_POLICY_CFM))
#define DM_LP_WRITE_ALWAYS_MASTER_DEVICES_REQ ((dm_prim_t)(ENUM_DM_LP_WRITE_ALWAYS_MASTER_DEVICES_REQ))
#define DM_LP_WRITE_ALWAYS_MASTER_DEVICES_CFM ((dm_prim_t)(ENUM_DM_LP_WRITE_ALWAYS_MASTER_DEVICES_CFM))

#define DM_SET_LINK_BEHAVIOR_REQ         ((dm_prim_t)(ENUM_DM_SET_LINK_BEHAVIOR_REQ))
#define DM_SET_LINK_BEHAVIOR_CFM         ((dm_prim_t)(ENUM_DM_SET_LINK_BEHAVIOR_CFM))

#define DM_BLUESTACK_STATE_TRANSITION_ENTRY_IND ((dm_prim_t)(ENUM_DM_BLUESTACK_STATE_TRANSITION_ENTRY_IND))
#define DM_BLUESTACK_STATE_TRANSITION_EXIT_IND ((dm_prim_t)(ENUM_DM_BLUESTACK_STATE_TRANSITION_EXIT_IND))

#define DM_HANDLE_DEVICE_BLACK_LIST_REQ ((dm_prim_t)ENUM_DM_HANDLE_DEVICE_BLACK_LIST_REQ)
#define DM_HANDLE_DEVICE_BLACK_LIST_CFM ((dm_prim_t)ENUM_DM_HANDLE_DEVICE_BLACK_LIST_CFM)
#define DM_HCI_CHANGE_ACL_CONN_PKT_TYPE_REQ ((dm_prim_t)ENUM_DM_HCI_CHANGE_ACL_CONN_PKT_TYPE_REQ)
#define DM_HCI_CHANGE_ACL_CONN_PKT_TYPE_CFM ((dm_prim_t)ENUM_DM_HCI_CHANGE_ACL_CONN_PKT_TYPE_CFM)
#define DM_ACL_CONN_HANDLE_IND           ((dm_prim_t)(ENUM_DM_ACL_CONN_HANDLE_IND))
#define DM_ACL_CONN_START_IND            ((dm_prim_t)(ENUM_DM_ACL_CONN_START_IND))
#define DM_ULP_ADV_PARAM_UPDATE_IND      ((dm_prim_t)(ENUM_DM_ULP_ADV_PARAM_UPDATE_IND))

#define DM_CRYPTO_GENERATE_PUBLIC_PRIVATE_KEY_REQ   ((dm_prim_t)(ENUM_DM_CRYPTO_GENERATE_PUBLIC_PRIVATE_KEY_REQ))
#define DM_CRYPTO_GENERATE_PUBLIC_PRIVATE_KEY_CFM   ((dm_prim_t)(ENUM_DM_CRYPTO_GENERATE_PUBLIC_PRIVATE_KEY_CFM))
#define DM_CRYPTO_GENERATE_SHARED_SECRET_KEY_REQ    ((dm_prim_t)(ENUM_DM_CRYPTO_GENERATE_SHARED_SECRET_KEY_REQ))
#define DM_CRYPTO_GENERATE_SHARED_SECRET_KEY_CFM    ((dm_prim_t)(ENUM_DM_CRYPTO_GENERATE_SHARED_SECRET_KEY_CFM))
#define DM_CRYPTO_ENCRYPT_REQ                       ((dm_prim_t)(ENUM_DM_CRYPTO_ENCRYPT_REQ))
#define DM_CRYPTO_ENCRYPT_CFM                       ((dm_prim_t)(ENUM_DM_CRYPTO_ENCRYPT_CFM))
#define DM_CRYPTO_DECRYPT_REQ                       ((dm_prim_t)(ENUM_DM_CRYPTO_DECRYPT_REQ))
#define DM_CRYPTO_DECRYPT_CFM                       ((dm_prim_t)(ENUM_DM_CRYPTO_DECRYPT_CFM))
#define DM_CRYPTO_HASH_REQ                          ((dm_prim_t)(ENUM_DM_CRYPTO_HASH_REQ))
#define DM_CRYPTO_HASH_CFM                          ((dm_prim_t)(ENUM_DM_CRYPTO_HASH_CFM))
#define DM_CRYPTO_AES_CTR_REQ                       ((dm_prim_t)(ENUM_DM_CRYPTO_AES_CTR_REQ))
#define DM_CRYPTO_AES_CTR_CFM                       ((dm_prim_t)(ENUM_DM_CRYPTO_AES_CTR_CFM))
#define DM_ULP_ENABLE_ZERO_SLAVE_LATENCY_REQ        ((dm_prim_t)(ENUM_DM_ULP_ENABLE_ZERO_SLAVE_LATENCY_REQ))
#define DM_ULP_ENABLE_ZERO_SLAVE_LATENCY_CFM        ((dm_prim_t)(ENUM_DM_ULP_ENABLE_ZERO_SLAVE_LATENCY_CFM))
#define DM_HCI_ULP_CHANNEL_SELECTION_ALGORITHM_IND  ((dm_prim_t)(ENUM_DM_HCI_ULP_CHANNEL_SELECTION_ALGORITHM_IND))

#define DM_ULP_SET_PHY_REQ           ((dm_prim_t)(ENUM_DM_ULP_SET_PHY_REQ))
#define DM_ULP_SET_PHY_CFM           ((dm_prim_t)(ENUM_DM_ULP_SET_PHY_CFM))
#define DM_ULP_SET_DEFAULT_PHY_REQ   ((dm_prim_t)(ENUM_DM_ULP_SET_DEFAULT_PHY_REQ))
#define DM_ULP_SET_DEFAULT_PHY_CFM   ((dm_prim_t)(ENUM_DM_ULP_SET_DEFAULT_PHY_CFM))
#define DM_ULP_PHY_UPDATE_IND        ((dm_prim_t)(ENUM_DM_ULP_PHY_UPDATE_IND))
#define DM_ULP_READ_PHY_REQ          ((dm_prim_t)(ENUM_DM_ULP_READ_PHY_REQ))
#define DM_ULP_READ_PHY_CFM          ((dm_prim_t)(ENUM_DM_ULP_READ_PHY_CFM))

#define DM_HCI_ULP_EXT_ADV_SET_DATA_REQ              ((dm_prim_t)(ENUM_DM_HCI_ULP_EXT_ADV_SET_DATA_REQ))
#define DM_HCI_ULP_EXT_ADV_SET_DATA_CFM              ((dm_prim_t)(ENUM_DM_HCI_ULP_EXT_ADV_SET_DATA_CFM))
#define DM_HCI_ULP_EXT_ADV_SET_SCAN_RESP_DATA_REQ    ((dm_prim_t)(ENUM_DM_HCI_ULP_EXT_ADV_SET_SCAN_RESP_DATA_REQ))
#define DM_HCI_ULP_EXT_ADV_SET_SCAN_RESP_DATA_CFM    ((dm_prim_t)(ENUM_DM_HCI_ULP_EXT_ADV_SET_SCAN_RESP_DATA_CFM))
#define DM_HCI_ULP_PERIODIC_ADV_SET_DATA_REQ         ((dm_prim_t)(ENUM_DM_HCI_ULP_PERIODIC_ADV_SET_DATA_REQ))
#define DM_HCI_ULP_PERIODIC_ADV_SET_DATA_CFM         ((dm_prim_t)(ENUM_DM_HCI_ULP_PERIODIC_ADV_SET_DATA_CFM))
#define DM_ULP_EXT_SCAN_CTRL_SCAN_INFO_IND           ((dm_prim_t)(ENUM_DM_ULP_EXT_SCAN_CTRL_SCAN_INFO_IND))
#define DM_ULP_GET_ADV_SCAN_CAPABILITIES_REQ         ((dm_prim_t)(ENUM_DM_ULP_GET_ADV_SCAN_CAPABILITIES_REQ))
#define DM_ULP_GET_ADV_SCAN_CAPABILITIES_CFM         ((dm_prim_t)(ENUM_DM_ULP_GET_ADV_SCAN_CAPABILITIES_CFM))
#define DM_ULP_SET_DATA_RELATED_ADDRESS_CHANGES_REQ  ((dm_prim_t)(ENUM_DM_ULP_SET_DATA_RELATED_ADDRESS_CHANGES_REQ))
#define DM_ULP_SET_DATA_RELATED_ADDRESS_CHANGES_CFM  ((dm_prim_t)(ENUM_DM_ULP_SET_DATA_RELATED_ADDRESS_CHANGES_CFM))
#define DM_ULP_EXT_ADV_SETS_INFO_REQ                 ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_SETS_INFO_REQ))
#define DM_ULP_EXT_ADV_SETS_INFO_CFM                 ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_SETS_INFO_CFM))
#define DM_ULP_EXT_ADV_REGISTER_APP_ADV_SET_REQ      ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_REGISTER_APP_ADV_SET_REQ))
#define DM_ULP_EXT_ADV_REGISTER_APP_ADV_SET_CFM      ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_REGISTER_APP_ADV_SET_CFM))
#define DM_ULP_EXT_ADV_UNREGISTER_APP_ADV_SET_REQ    ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_UNREGISTER_APP_ADV_SET_REQ))
#define DM_ULP_EXT_ADV_UNREGISTER_APP_ADV_SET_CFM    ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_UNREGISTER_APP_ADV_SET_CFM))
#define DM_ULP_EXT_ADV_SET_PARAMS_REQ                ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_SET_PARAMS_REQ))
#define DM_ULP_EXT_ADV_SET_PARAMS_CFM                ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_SET_PARAMS_CFM))
#define DM_ULP_EXT_ADV_SET_PARAMS_V2_REQ             ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_SET_PARAMS_V2_REQ))
#define DM_ULP_EXT_ADV_SET_PARAMS_V2_CFM             ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_SET_PARAMS_V2_CFM))
#define DM_ULP_EXT_ADV_ENABLE_REQ                    ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_ENABLE_REQ))
#define DM_ULP_EXT_ADV_ENABLE_CFM                    ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_ENABLE_CFM))
#define DM_ULP_EXT_ADV_MULTI_ENABLE_REQ              ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_MULTI_ENABLE_REQ))
#define DM_ULP_EXT_ADV_MULTI_ENABLE_CFM              ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_MULTI_ENABLE_CFM))
#define DM_ULP_EXT_ADV_GET_ADDR_REQ                  ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_GET_ADDR_REQ))
#define DM_ULP_EXT_ADV_GET_ADDR_CFM                  ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_GET_ADDR_CFM))
#define DM_ULP_EXT_ADV_READ_MAX_ADV_DATA_LEN_REQ     ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_READ_MAX_ADV_DATA_LEN_REQ))
#define DM_ULP_EXT_ADV_READ_MAX_ADV_DATA_LEN_CFM     ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_READ_MAX_ADV_DATA_LEN_CFM))
#define DM_ULP_EXT_ADV_SET_RANDOM_ADDR_REQ           ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_SET_RANDOM_ADDR_REQ))
#define DM_ULP_EXT_ADV_SET_RANDOM_ADDR_CFM           ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_SET_RANDOM_ADDR_CFM))
#define DM_ULP_EXT_SCAN_GET_GLOBAL_PARAMS_REQ        ((dm_prim_t)(ENUM_DM_ULP_EXT_SCAN_GET_GLOBAL_PARAMS_REQ))
#define DM_ULP_EXT_SCAN_GET_GLOBAL_PARAMS_CFM        ((dm_prim_t)(ENUM_DM_ULP_EXT_SCAN_GET_GLOBAL_PARAMS_CFM))
#define DM_ULP_EXT_SCAN_SET_GLOBAL_PARAMS_REQ        ((dm_prim_t)(ENUM_DM_ULP_EXT_SCAN_SET_GLOBAL_PARAMS_REQ))
#define DM_ULP_EXT_SCAN_SET_GLOBAL_PARAMS_CFM        ((dm_prim_t)(ENUM_DM_ULP_EXT_SCAN_SET_GLOBAL_PARAMS_CFM))
#define DM_ULP_EXT_SCAN_REGISTER_SCANNER_REQ         ((dm_prim_t)(ENUM_DM_ULP_EXT_SCAN_REGISTER_SCANNER_REQ))
#define DM_ULP_EXT_SCAN_REGISTER_SCANNER_CFM         ((dm_prim_t)(ENUM_DM_ULP_EXT_SCAN_REGISTER_SCANNER_CFM))
#define DM_ULP_EXT_SCAN_UNREGISTER_SCANNER_REQ       ((dm_prim_t)(ENUM_DM_ULP_EXT_SCAN_UNREGISTER_SCANNER_REQ))
#define DM_ULP_EXT_SCAN_UNREGISTER_SCANNER_CFM       ((dm_prim_t)(ENUM_DM_ULP_EXT_SCAN_UNREGISTER_SCANNER_CFM))
#ifndef EXCLUDE_AE_REPORTS
#define DM_ULP_EXT_SCAN_CONFIGURE_SCANNER_REQ        ((dm_prim_t)(ENUM_DM_ULP_EXT_SCAN_CONFIGURE_SCANNER_REQ))
#define DM_ULP_EXT_SCAN_CONFIGURE_SCANNER_CFM        ((dm_prim_t)(ENUM_DM_ULP_EXT_SCAN_CONFIGURE_SCANNER_CFM))
#endif /* EXCLUDE_AE_REPORTS */
#define DM_ULP_EXT_SCAN_ENABLE_SCANNERS_REQ          ((dm_prim_t)(ENUM_DM_ULP_EXT_SCAN_ENABLE_SCANNERS_REQ))
#define DM_ULP_EXT_SCAN_ENABLE_SCANNERS_CFM          ((dm_prim_t)(ENUM_DM_ULP_EXT_SCAN_ENABLE_SCANNERS_CFM))
#define DM_ULP_EXT_SCAN_GET_CTRL_SCAN_INFO_REQ       ((dm_prim_t)(ENUM_DM_ULP_EXT_SCAN_GET_CTRL_SCAN_INFO_REQ))
#define DM_ULP_EXT_SCAN_GET_CTRL_SCAN_INFO_CFM       ((dm_prim_t)(ENUM_DM_ULP_EXT_SCAN_GET_CTRL_SCAN_INFO_CFM))
#define DM_ULP_EXT_SCAN_TIMEOUT_IND                  ((dm_prim_t)(ENUM_DM_ULP_EXT_SCAN_TIMEOUT_IND))

#ifndef EXCLUDE_AE_REPORTS
#define DM_ULP_EXT_SCAN_FILTERED_ADV_REPORT_IND      ((dm_prim_t)(ENUM_DM_ULP_EXT_SCAN_FILTERED_ADV_REPORT_IND))
#endif /* EXCLUDE_AE_REPORTS */
#define DM_ULP_PERIODIC_ADV_SET_PARAMS_REQ           ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_ADV_SET_PARAMS_REQ))
#define DM_ULP_PERIODIC_ADV_SET_PARAMS_CFM           ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_ADV_SET_PARAMS_CFM))
#define DM_ULP_PERIODIC_ADV_READ_MAX_ADV_DATA_LEN_REQ ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_ADV_READ_MAX_ADV_DATA_LEN_REQ))
#define DM_ULP_PERIODIC_ADV_READ_MAX_ADV_DATA_LEN_CFM ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_ADV_READ_MAX_ADV_DATA_LEN_CFM))
#define DM_ULP_PERIODIC_ADV_START_REQ                ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_ADV_START_REQ))
#define DM_ULP_PERIODIC_ADV_START_CFM                ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_ADV_START_CFM))
#define DM_ULP_PERIODIC_ADV_STOP_REQ                 ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_ADV_STOP_REQ))
#define DM_ULP_PERIODIC_ADV_STOP_CFM                 ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_ADV_STOP_CFM))
#define DM_ULP_PERIODIC_ADV_ENABLE_REQ               ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_ADV_ENABLE_REQ))
#define DM_ULP_PERIODIC_ADV_ENABLE_CFM               ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_ADV_ENABLE_CFM))
#define DM_ULP_PERIODIC_ADV_SET_TRANSFER_REQ               ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_ADV_SET_TRANSFER_REQ))
#define DM_ULP_PERIODIC_ADV_SET_TRANSFER_CFM               ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_ADV_SET_TRANSFER_CFM))
#define DM_ULP_PERIODIC_SCAN_START_FIND_TRAINS_REQ         ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_START_FIND_TRAINS_REQ))
#define DM_ULP_PERIODIC_SCAN_START_FIND_TRAINS_CFM         ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_START_FIND_TRAINS_CFM))
#define DM_ULP_PERIODIC_SCAN_STOP_FIND_TRAINS_REQ          ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_STOP_FIND_TRAINS_REQ))
#define DM_ULP_PERIODIC_SCAN_STOP_FIND_TRAINS_CFM          ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_STOP_FIND_TRAINS_CFM))
#define DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_REQ             ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_REQ))
#define DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CFM             ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CFM))
#define DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CANCEL_REQ      ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CANCEL_REQ))
#define DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CANCEL_CFM      ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CANCEL_CFM))
#define DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_ENABLE_REQ    ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_ENABLE_REQ))
#define DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_ENABLE_CFM    ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_ENABLE_CFM))
#define DM_ULP_PERIODIC_SCAN_SYNC_TERMINATE_REQ            ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TERMINATE_REQ))
#define DM_ULP_PERIODIC_SCAN_SYNC_TERMINATE_CFM            ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TERMINATE_CFM))
#ifndef EXCLUDE_AE_REPORTS
#define DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_IND           ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_IND))
#endif /* EXCLUDE_AE_REPORTS */
#define DM_ULP_PERIODIC_SCAN_SYNC_LOST_IND                 ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_SYNC_LOST_IND))
#define DM_ULP_PERIODIC_SCAN_SYNC_LOST_RSP                 ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_SYNC_LOST_RSP))
#define DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_REQ             ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_REQ))
#define DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_CFM             ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_CFM))
#define DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_IND             ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_IND))
#define DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_PARAMS_REQ      ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_PARAMS_REQ))
#define DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_PARAMS_CFM      ((dm_prim_t)(ENUM_DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_PARAMS_CFM))
#define DM_ULP_EXT_SCAN_DURATION_EXPIRED_IND               ((dm_prim_t)(ENUM_DM_ULP_EXT_SCAN_DURATION_EXPIRED_IND))
#define DM_ULP_EXT_ADV_TERMINATED_IND                      ((dm_prim_t)(ENUM_DM_ULP_EXT_ADV_TERMINATED_IND))

#define DM_ULP_ENHANCED_READ_TRANSMIT_POWER_LEVEL_REQ      ((dm_prim_t)(ENUM_DM_ULP_ENHANCED_READ_TRANSMIT_POWER_LEVEL_REQ))
#define DM_ULP_ENHANCED_READ_TRANSMIT_POWER_LEVEL_CFM      ((dm_prim_t)(ENUM_DM_ULP_ENHANCED_READ_TRANSMIT_POWER_LEVEL_CFM))
#define DM_ULP_READ_REMOTE_TRANSMIT_POWER_LEVEL_REQ        ((dm_prim_t)(ENUM_DM_ULP_READ_REMOTE_TRANSMIT_POWER_LEVEL_REQ))
#define DM_ULP_READ_REMOTE_TRANSMIT_POWER_LEVEL_CFM        ((dm_prim_t)(ENUM_DM_ULP_READ_REMOTE_TRANSMIT_POWER_LEVEL_CFM))
#define DM_ULP_TRANSMIT_POWER_REPORTING_IND                ((dm_prim_t)(ENUM_DM_ULP_TRANSMIT_POWER_REPORTING_IND))
#define DM_ULP_SET_PATH_LOSS_REPORTING_PARAMETERS_REQ      ((dm_prim_t)(ENUM_DM_ULP_SET_PATH_LOSS_REPORTING_PARAMETERS_REQ))
#define DM_ULP_SET_PATH_LOSS_REPORTING_PARAMETERS_CFM      ((dm_prim_t)(ENUM_DM_ULP_SET_PATH_LOSS_REPORTING_PARAMETERS_CFM))
#define DM_ULP_SET_PATH_LOSS_REPORTING_ENABLE_REQ          ((dm_prim_t)(ENUM_DM_ULP_SET_PATH_LOSS_REPORTING_ENABLE_REQ))
#define DM_ULP_SET_PATH_LOSS_REPORTING_ENABLE_CFM          ((dm_prim_t)(ENUM_DM_ULP_SET_PATH_LOSS_REPORTING_ENABLE_CFM))
#define DM_ULP_SET_TRANSMIT_POWER_REPORTING_ENABLE_REQ     ((dm_prim_t)(ENUM_DM_ULP_SET_TRANSMIT_POWER_REPORTING_ENABLE_REQ))
#define DM_ULP_SET_TRANSMIT_POWER_REPORTING_ENABLE_CFM     ((dm_prim_t)(ENUM_DM_ULP_SET_TRANSMIT_POWER_REPORTING_ENABLE_CFM))
#define DM_ULP_PATH_LOSS_THRESHOLD_IND                     ((dm_prim_t)(ENUM_DM_ULP_PATH_LOSS_THRESHOLD_IND))

/*-------------------------------------------------------------
  Internal DM/AMPM Interface
  ---------------------------------------------------------------*/
#define DM_AMPM_REGISTER_REQ                ((dm_prim_t)(ENUM_DM_AMPM_REGISTER_REQ))
#define DM_AMPM_CONNECT_RSP                 ((dm_prim_t)(ENUM_DM_AMPM_CONNECT_RSP))
#define DM_AMPM_CONNECT_CHANNEL_RSP         ((dm_prim_t)(ENUM_DM_AMPM_CONNECT_CHANNEL_RSP))
#define DM_AMPM_DISCONNECT_CHANNEL_RSP      ((dm_prim_t)(ENUM_DM_AMPM_DISCONNECT_CHANNEL_RSP))
#define DM_AMPM_DISCONNECT_REQ              ((dm_prim_t)(ENUM_DM_AMPM_DISCONNECT_REQ))
#define DM_AMPM_READ_BD_ADDR_REQ            ((dm_prim_t)(ENUM_DM_AMPM_READ_BD_ADDR_REQ))
#define DM_AMPM_VERIFY_PHYSICAL_LINK_RSP    ((dm_prim_t)(ENUM_DM_AMPM_VERIFY_PHYSICAL_LINK_RSP))
#define DM_AMPM_READ_DATA_BLOCK_SIZE_RSP    ((dm_prim_t)(ENUM_DM_AMPM_READ_DATA_BLOCK_SIZE_RSP))
#define DM_AMPM_NUMBER_COMPLETED_DATA_BLOCKS_REQ ((dm_prim_t)(ENUM_DM_AMPM_NUMBER_COMPLETED_DATA_BLOCKS_REQ))

#define DM_AMPM_REGISTER_CFM                ((dm_prim_t)(ENUM_DM_AMPM_REGISTER_CFM))
#define DM_AMPM_CONNECT_IND                 ((dm_prim_t)(ENUM_DM_AMPM_CONNECT_IND))
#define DM_AMPM_CONNECT_CHANNEL_IND         ((dm_prim_t)(ENUM_DM_AMPM_CONNECT_CHANNEL_IND))
#define DM_AMPM_DISCONNECT_CHANNEL_IND      ((dm_prim_t)(ENUM_DM_AMPM_DISCONNECT_CHANNEL_IND))
#define DM_AMPM_LINK_KEY_NOTIFICATION_IND   ((dm_prim_t)(ENUM_DM_AMPM_LINK_KEY_NOTIFICATION_IND))
#define DM_AMPM_READ_BD_ADDR_CFM            ((dm_prim_t)(ENUM_DM_AMPM_READ_BD_ADDR_CFM))
#define DM_AMPM_VERIFY_PHYSICAL_LINK_IND    ((dm_prim_t)(ENUM_DM_AMPM_VERIFY_PHYSICAL_LINK_IND))
#define DM_AMPM_READ_DATA_BLOCK_SIZE_IND    ((dm_prim_t)(ENUM_DM_AMPM_READ_DATA_BLOCK_SIZE_IND))
#define DM_AMPM_SIMPLE_PAIRING_ENABLED_IND  ((dm_prim_t)(ENUM_DM_AMPM_SIMPLE_PAIRING_ENABLED_IND))
#define DM_AMPM_REMOTE_FEATURES_IND         ((dm_prim_t)(ENUM_DM_AMPM_REMOTE_FEATURES_IND))

/*-------------------------------------------------------------
  Internal Device Manager HCI data interface. Not for application use.
  ---------------------------------------------------------------*/
#define DM_DATA_FROM_HCI_REQ    ((dm_prim_t)ENUM_DM_DATA_FROM_HCI_REQ)
#define DM_DATA_TO_HCI_IND      ((dm_prim_t)ENUM_DM_DATA_TO_HCI_IND)

/*-------------------------------------------------------------
HCI API primitives
---------------------------------------------------------------*/

/******************************************************************************
 Link Control
 *****************************************************************************/

/*-------------------------------------------------------------
Downstream primitives
---------------------------------------------------------------*/
#define DM_HCI_INQUIRY_REQ                        ((dm_prim_t) ENUM_DM_HCI_INQUIRY_REQ)
#define DM_HCI_INQUIRY_CANCEL_REQ                 ((dm_prim_t) ENUM_DM_HCI_INQUIRY_CANCEL_REQ)
#define DM_HCI_PERIODIC_INQUIRY_MODE_REQ          ((dm_prim_t) ENUM_DM_HCI_PERIODIC_INQUIRY_MODE_REQ)
#define DM_HCI_EXIT_PERIODIC_INQUIRY_MODE_REQ     ((dm_prim_t) ENUM_DM_HCI_EXIT_PERIODIC_INQUIRY_MODE_REQ)
#define DM_HCI_CHANGE_CONN_PKT_TYPE_REQ           ((dm_prim_t) ENUM_DM_HCI_CHANGE_CONN_PKT_TYPE_REQ)
#define DM_HCI_CHANGE_CONN_LINK_KEY_REQ           ((dm_prim_t) ENUM_DM_HCI_CHANGE_CONN_LINK_KEY_REQ)
#define DM_HCI_MASTER_LINK_KEY_REQ                ((dm_prim_t) ENUM_DM_HCI_MASTER_LINK_KEY_REQ)
#define DM_HCI_REMOTE_NAME_REQUEST_REQ            ((dm_prim_t) ENUM_DM_HCI_REMOTE_NAME_REQUEST_REQ)
#define DM_HCI_READ_REMOTE_SUPP_FEATURES_REQ      ((dm_prim_t) ENUM_DM_HCI_READ_REMOTE_SUPP_FEATURES_REQ)
#define DM_HCI_READ_REMOTE_VER_INFO_REQ           ((dm_prim_t) ENUM_DM_HCI_READ_REMOTE_VER_INFO_REQ)
#define DM_HCI_READ_CLOCK_OFFSET_REQ              ((dm_prim_t) ENUM_DM_HCI_READ_CLOCK_OFFSET_REQ)
#define DM_HCI_TRUNCATED_PAGE_REQ                 ((dm_prim_t) ENUM_DM_HCI_TRUNCATED_PAGE_REQ)
#define DM_HCI_TRUNCATED_PAGE_CANCEL_REQ          ((dm_prim_t) ENUM_DM_HCI_TRUNCATED_PAGE_CANCEL_REQ)
#define DM_HCI_SET_CSB_REQ                        ((dm_prim_t) ENUM_DM_HCI_SET_CSB_REQ)
#define DM_HCI_SET_CSB_RECEIVE_REQ                ((dm_prim_t) ENUM_DM_HCI_SET_CSB_RECEIVE_REQ)
#define DM_HCI_START_SYNCHRONIZATION_TRAIN_REQ    ((dm_prim_t) ENUM_DM_HCI_START_SYNCHRONIZATION_TRAIN_REQ)
#define DM_HCI_RECEIVE_SYNCHRONIZATION_TRAIN_REQ  ((dm_prim_t) ENUM_DM_HCI_RECEIVE_SYNCHRONIZATION_TRAIN_REQ)

/*-------------------------------------------------------------
Upstream primitives
---------------------------------------------------------------*/
#define DM_HCI_INQUIRY_CANCEL_CFM                 ((dm_prim_t)ENUM_DM_HCI_INQUIRY_CANCEL_CFM)
#define DM_HCI_PERIODIC_INQUIRY_MODE_CFM          ((dm_prim_t)ENUM_DM_HCI_PERIODIC_INQUIRY_MODE_CFM)
#define DM_HCI_EXIT_PERIODIC_INQUIRY_MODE_CFM     ((dm_prim_t)ENUM_DM_HCI_EXIT_PERIODIC_INQUIRY_MODE_CFM)
#define DM_HCI_INQUIRY_RESULT_IND                 ((dm_prim_t)ENUM_DM_HCI_INQUIRY_RESULT_IND)
#define DM_HCI_INQUIRY_CFM                        ((dm_prim_t)ENUM_DM_HCI_INQUIRY_CFM)
#define DM_HCI_CHANGE_CONN_LINK_KEY_CFM           ((dm_prim_t)ENUM_DM_HCI_CHANGE_CONN_LINK_KEY_CFM)
#define DM_HCI_RETURN_LINK_KEYS_IND               ((dm_prim_t)ENUM_DM_HCI_RETURN_LINK_KEYS_IND)
#define DM_HCI_MASTER_LINK_KEY_CFM                ((dm_prim_t)ENUM_DM_HCI_MASTER_LINK_KEY_CFM)
#define DM_HCI_REMOTE_NAME_CFM                    ((dm_prim_t)ENUM_DM_HCI_REMOTE_NAME_CFM)
#define DM_HCI_READ_REMOTE_SUPP_FEATURES_CFM      ((dm_prim_t)ENUM_DM_HCI_READ_REMOTE_SUPP_FEATURES_CFM)
#define DM_HCI_READ_REMOTE_VER_INFO_CFM           ((dm_prim_t)ENUM_DM_HCI_READ_REMOTE_VER_INFO_CFM)
#define DM_HCI_READ_CLOCK_OFFSET_CFM              ((dm_prim_t)ENUM_DM_HCI_READ_CLOCK_OFFSET_CFM)
#define DM_HCI_TRUNCATED_PAGE_CFM                 ((dm_prim_t)ENUM_DM_HCI_TRUNCATED_PAGE_CFM)
#define DM_HCI_TRUNCATED_PAGE_CANCEL_CFM          ((dm_prim_t)ENUM_DM_HCI_TRUNCATED_PAGE_CANCEL_CFM)
#define DM_HCI_SET_CSB_CFM                        ((dm_prim_t)ENUM_DM_HCI_SET_CSB_CFM)
#define DM_HCI_SET_CSB_RECEIVE_CFM                ((dm_prim_t)ENUM_DM_HCI_SET_CSB_RECEIVE_CFM)
#define DM_HCI_START_SYNCHRONIZATION_TRAIN_CFM    ((dm_prim_t)ENUM_DM_HCI_START_SYNCHRONIZATION_TRAIN_CFM)
#define DM_HCI_RECEIVE_SYNCHRONIZATION_TRAIN_CFM  ((dm_prim_t)ENUM_DM_HCI_RECEIVE_SYNCHRONIZATION_TRAIN_CFM)

#define DM_HCI_CSB_RECEIVE_IND                    ((dm_prim_t)ENUM_DM_HCI_CSB_RECEIVE_IND)
#define DM_HCI_CSB_TIMEOUT_IND                    ((dm_prim_t)ENUM_DM_HCI_CSB_TIMEOUT_IND)
#define DM_HCI_CSB_CHANNEL_MAP_CHANGE_IND         ((dm_prim_t)ENUM_DM_HCI_CSB_CHANNEL_MAP_CHANGE_IND)
#define DM_HCI_SLAVE_PAGE_RESPONSE_TIMEOUT_IND    ((dm_prim_t)ENUM_DM_HCI_SLAVE_PAGE_RESPONSE_TIMEOUT_IND)
#define DM_HCI_CSB_AFH_MAP_AVAILABLE_IND          ((dm_prim_t)(ENUM_DM_HCI_CSB_AFH_MAP_AVAILABLE_IND))

/******************************************************************************
   Link Policy
 *****************************************************************************/
/*-------------------------------------------------------------
Downstream primitives
---------------------------------------------------------------*/
#define DM_HCI_HOLD_MODE_REQ                    ((dm_prim_t) ENUM_DM_HCI_HOLD_MODE_REQ)
#define DM_HCI_SNIFF_MODE_REQ                   ((dm_prim_t) ENUM_DM_HCI_SNIFF_MODE_REQ)
#define DM_HCI_EXIT_SNIFF_MODE_REQ              ((dm_prim_t) ENUM_DM_HCI_EXIT_SNIFF_MODE_REQ)
#define DM_HCI_QOS_SETUP_REQ                    ((dm_prim_t) ENUM_DM_HCI_QOS_SETUP_REQ)
#define DM_HCI_ROLE_DISCOVERY_REQ               ((dm_prim_t) ENUM_DM_HCI_ROLE_DISCOVERY_REQ)
#define DM_HCI_SWITCH_ROLE_REQ                  ((dm_prim_t) ENUM_DM_HCI_SWITCH_ROLE_REQ)
#define DM_HCI_READ_LINK_POLICY_SETTINGS_REQ    ((dm_prim_t) ENUM_DM_HCI_READ_LINK_POLICY_SETTINGS_REQ)
#define DM_HCI_WRITE_LINK_POLICY_SETTINGS_REQ   ((dm_prim_t) ENUM_DM_HCI_WRITE_LINK_POLICY_SETTINGS_REQ)


/*-------------------------------------------------------------
Upstream primitives
---------------------------------------------------------------*/
#define DM_HCI_MODE_CHANGE_EVENT_IND            ((dm_prim_t)ENUM_DM_HCI_MODE_CHANGE_EVENT_IND)
#define DM_HCI_QOS_SETUP_CFM                    ((dm_prim_t)ENUM_DM_HCI_QOS_SETUP_CFM)
#define DM_HCI_ROLE_DISCOVERY_CFM               ((dm_prim_t)ENUM_DM_HCI_ROLE_DISCOVERY_CFM)
#define DM_HCI_SWITCH_ROLE_CFM                  ((dm_prim_t)ENUM_DM_HCI_SWITCH_ROLE_CFM)
#define DM_HCI_READ_LINK_POLICY_SETTINGS_CFM    ((dm_prim_t)ENUM_DM_HCI_READ_LINK_POLICY_SETTINGS_CFM)
#define DM_HCI_WRITE_LINK_POLICY_SETTINGS_CFM   ((dm_prim_t)ENUM_DM_HCI_WRITE_LINK_POLICY_SETTINGS_CFM)

/******************************************************************************
   Host Controller and Baseband
 *****************************************************************************/
/*-------------------------------------------------------------
Downstream primitives
---------------------------------------------------------------*/
#define DM_HCI_SET_EVENT_MASK_REQ                        ((dm_prim_t) ENUM_DM_HCI_SET_EVENT_MASK_REQ)
#define DM_HCI_RESET_REQ                                 ((dm_prim_t) ENUM_DM_HCI_RESET_REQ)
#define DM_HCI_SET_EVENT_FILTER_REQ                      ((dm_prim_t) ENUM_DM_HCI_SET_EVENT_FILTER_REQ)
#define DM_HCI_FLUSH_REQ                                 ((dm_prim_t) ENUM_DM_HCI_FLUSH_REQ)
#define DM_HCI_READ_PIN_TYPE_REQ                         ((dm_prim_t) ENUM_DM_HCI_READ_PIN_TYPE_REQ)
#define DM_HCI_WRITE_PIN_TYPE_REQ                        ((dm_prim_t) ENUM_DM_HCI_WRITE_PIN_TYPE_REQ)
#define DM_HCI_READ_STORED_LINK_KEY_REQ                  ((dm_prim_t) ENUM_DM_HCI_READ_STORED_LINK_KEY_REQ)
#define DM_HCI_WRITE_STORED_LINK_KEY_REQ                 ((dm_prim_t) ENUM_DM_HCI_WRITE_STORED_LINK_KEY_REQ)
#define DM_HCI_DELETE_STORED_LINK_KEY_REQ                ((dm_prim_t) ENUM_DM_HCI_DELETE_STORED_LINK_KEY_REQ)
#define DM_HCI_CHANGE_LOCAL_NAME_REQ                     ((dm_prim_t) ENUM_DM_HCI_CHANGE_LOCAL_NAME_REQ)
#define DM_HCI_READ_LOCAL_NAME_REQ                       ((dm_prim_t) ENUM_DM_HCI_READ_LOCAL_NAME_REQ)
#define DM_HCI_READ_CONN_ACCEPT_TIMEOUT_REQ              ((dm_prim_t) ENUM_DM_HCI_READ_CONN_ACCEPT_TIMEOUT_REQ)
#define DM_HCI_WRITE_CONN_ACCEPT_TIMEOUT_REQ             ((dm_prim_t) ENUM_DM_HCI_WRITE_CONN_ACCEPT_TIMEOUT_REQ)
#define DM_HCI_READ_PAGE_TIMEOUT_REQ                     ((dm_prim_t) ENUM_DM_HCI_READ_PAGE_TIMEOUT_REQ)
#define DM_HCI_WRITE_PAGE_TIMEOUT_REQ                    ((dm_prim_t) ENUM_DM_HCI_WRITE_PAGE_TIMEOUT_REQ)
#define DM_HCI_READ_SCAN_ENABLE_REQ                      ((dm_prim_t) ENUM_DM_HCI_READ_SCAN_ENABLE_REQ)
#define DM_HCI_WRITE_SCAN_ENABLE_REQ                     ((dm_prim_t) ENUM_DM_HCI_WRITE_SCAN_ENABLE_REQ)
#define DM_HCI_READ_PAGESCAN_ACTIVITY_REQ                ((dm_prim_t) ENUM_DM_HCI_READ_PAGESCAN_ACTIVITY_REQ)
#define DM_HCI_WRITE_PAGESCAN_ACTIVITY_REQ               ((dm_prim_t) ENUM_DM_HCI_WRITE_PAGESCAN_ACTIVITY_REQ)
#define DM_HCI_READ_INQUIRYSCAN_ACTIVITY_REQ             ((dm_prim_t) ENUM_DM_HCI_READ_INQUIRYSCAN_ACTIVITY_REQ)
#define DM_HCI_WRITE_INQUIRYSCAN_ACTIVITY_REQ            ((dm_prim_t) ENUM_DM_HCI_WRITE_INQUIRYSCAN_ACTIVITY_REQ)
#define DM_HCI_READ_AUTH_ENABLE_REQ                      ((dm_prim_t) ENUM_DM_HCI_READ_AUTH_ENABLE_REQ)
#define DM_HCI_READ_ENC_MODE_REQ                         ((dm_prim_t) ENUM_DM_HCI_READ_ENC_MODE_REQ)
#define DM_HCI_READ_CLASS_OF_DEVICE_REQ                  ((dm_prim_t) ENUM_DM_HCI_READ_CLASS_OF_DEVICE_REQ)
#define DM_HCI_WRITE_CLASS_OF_DEVICE_REQ                 ((dm_prim_t) ENUM_DM_HCI_WRITE_CLASS_OF_DEVICE_REQ)
#define DM_HCI_READ_VOICE_SETTING_REQ                    ((dm_prim_t) ENUM_DM_HCI_READ_VOICE_SETTING_REQ)
#define DM_HCI_WRITE_VOICE_SETTING_REQ                   ((dm_prim_t) ENUM_DM_HCI_WRITE_VOICE_SETTING_REQ)
#define DM_HCI_READ_AUTO_FLUSH_TIMEOUT_REQ               ((dm_prim_t) ENUM_DM_HCI_READ_AUTO_FLUSH_TIMEOUT_REQ)
#define DM_HCI_WRITE_AUTO_FLUSH_TIMEOUT_REQ              ((dm_prim_t) ENUM_DM_HCI_WRITE_AUTO_FLUSH_TIMEOUT_REQ)
#define DM_HCI_READ_NUM_BCAST_RETXS_REQ                  ((dm_prim_t) ENUM_DM_HCI_READ_NUM_BCAST_RETXS_REQ)
#define DM_HCI_WRITE_NUM_BCAST_RETXS_REQ                 ((dm_prim_t) ENUM_DM_HCI_WRITE_NUM_BCAST_RETXS_REQ)
#define DM_HCI_READ_HOLD_MODE_ACTIVITY_REQ               ((dm_prim_t) ENUM_DM_HCI_READ_HOLD_MODE_ACTIVITY_REQ)
#define DM_HCI_WRITE_HOLD_MODE_ACTIVITY_REQ              ((dm_prim_t) ENUM_DM_HCI_WRITE_HOLD_MODE_ACTIVITY_REQ)
#define DM_HCI_READ_TX_POWER_LEVEL_REQ                   ((dm_prim_t) ENUM_DM_HCI_READ_TX_POWER_LEVEL_REQ)
#define DM_HCI_READ_SCO_FLOW_CON_ENABLE_REQ              ((dm_prim_t) ENUM_DM_HCI_READ_SCO_FLOW_CON_ENABLE_REQ)
#define DM_HCI_WRITE_SCO_FLOW_CON_ENABLE_REQ             ((dm_prim_t) ENUM_DM_HCI_WRITE_SCO_FLOW_CON_ENABLE_REQ)
#define DM_HCI_HOST_NUM_COMPLETED_PACKETS_REQ            ((dm_prim_t) ENUM_DM_HCI_HOST_NUM_COMPLETED_PACKETS_REQ)
#define DM_HCI_READ_LINK_SUPERV_TIMEOUT_REQ              ((dm_prim_t) ENUM_DM_HCI_READ_LINK_SUPERV_TIMEOUT_REQ)
#define DM_HCI_WRITE_LINK_SUPERV_TIMEOUT_REQ             ((dm_prim_t) ENUM_DM_HCI_WRITE_LINK_SUPERV_TIMEOUT_REQ)
#define DM_HCI_READ_NUM_SUPPORTED_IAC_REQ                ((dm_prim_t) ENUM_DM_HCI_READ_NUM_SUPPORTED_IAC_REQ)
#define DM_HCI_READ_CURRENT_IAC_LAP_REQ                  ((dm_prim_t) ENUM_DM_HCI_READ_CURRENT_IAC_LAP_REQ)
#define DM_HCI_WRITE_CURRENT_IAC_LAP_REQ                 ((dm_prim_t) ENUM_DM_HCI_WRITE_CURRENT_IAC_LAP_REQ)
#define DM_HCI_READ_PAGESCAN_PERIOD_MODE_REQ             ((dm_prim_t) ENUM_DM_HCI_READ_PAGESCAN_PERIOD_MODE_REQ)
#define DM_HCI_WRITE_PAGESCAN_PERIOD_MODE_REQ            ((dm_prim_t) ENUM_DM_HCI_WRITE_PAGESCAN_PERIOD_MODE_REQ)
#define DM_HCI_READ_PAGESCAN_MODE_REQ                    ((dm_prim_t) ENUM_DM_HCI_READ_PAGESCAN_MODE_REQ)
#define DM_HCI_WRITE_PAGESCAN_MODE_REQ                   ((dm_prim_t) ENUM_DM_HCI_WRITE_PAGESCAN_MODE_REQ)
#define DM_HCI_READ_SECURE_CONNECTIONS_HOST_SUPPORT_REQ  ((dm_prim_t) ENUM_DM_HCI_READ_SECURE_CONNECTIONS_HOST_SUPPORT_REQ)
#define DM_HCI_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT_REQ ((dm_prim_t) ENUM_DM_HCI_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT_REQ)
#define DM_HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_REQ    ((dm_prim_t) ENUM_DM_HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_REQ)
#define DM_HCI_SET_RESERVED_LT_ADDR_REQ                  ((dm_prim_t) ENUM_DM_HCI_SET_RESERVED_LT_ADDR_REQ)
#define DM_HCI_DELETE_RESERVED_LT_ADDR_REQ               ((dm_prim_t) ENUM_DM_HCI_DELETE_RESERVED_LT_ADDR_REQ)
#define DM_HCI_SET_CSB_DATA_REQ                          ((dm_prim_t) ENUM_DM_HCI_SET_CSB_DATA_REQ)
#define DM_HCI_WRITE_SYNCHRONIZATION_TRAIN_PARAMS_REQ    ((dm_prim_t) ENUM_DM_HCI_WRITE_SYNCHRONIZATION_TRAIN_PARAMS_REQ)
#define DM_HCI_READ_SYNCHRONIZATION_TRAIN_PARAMS_REQ     ((dm_prim_t) ENUM_DM_HCI_READ_SYNCHRONIZATION_TRAIN_PARAMS_REQ)
#define DM_HCI_CONFIGURE_DATA_PATH_REQ                   ((dm_prim_t) ENUM_DM_HCI_CONFIGURE_DATA_PATH_REQ)

/*-------------------------------------------------------------
Upstream primitives
---------------------------------------------------------------*/
#define DM_HCI_SET_EVENT_MASK_CFM                        ((dm_prim_t)ENUM_DM_HCI_SET_EVENT_MASK_CFM)
#define DM_HCI_RESET_CFM                                 ((dm_prim_t)ENUM_DM_HCI_RESET_CFM)
#define DM_HCI_SET_EVENT_FILTER_CFM                      ((dm_prim_t)ENUM_DM_HCI_SET_EVENT_FILTER_CFM)
#define DM_HCI_FLUSH_CFM                                 ((dm_prim_t)ENUM_DM_HCI_FLUSH_CFM)
#define DM_HCI_READ_PIN_TYPE_CFM                         ((dm_prim_t)ENUM_DM_HCI_READ_PIN_TYPE_CFM)
#define DM_HCI_WRITE_PIN_TYPE_CFM                        ((dm_prim_t)ENUM_DM_HCI_WRITE_PIN_TYPE_CFM)
#define DM_HCI_READ_STORED_LINK_KEY_CFM                  ((dm_prim_t)ENUM_DM_HCI_READ_STORED_LINK_KEY_CFM)
#define DM_HCI_WRITE_STORED_LINK_KEY_CFM                 ((dm_prim_t)ENUM_DM_HCI_WRITE_STORED_LINK_KEY_CFM)
#define DM_HCI_DELETE_STORED_LINK_KEY_CFM                ((dm_prim_t)ENUM_DM_HCI_DELETE_STORED_LINK_KEY_CFM)
#define DM_HCI_CHANGE_LOCAL_NAME_CFM                     ((dm_prim_t)ENUM_DM_HCI_CHANGE_LOCAL_NAME_CFM)
#define DM_HCI_READ_LOCAL_NAME_CFM                       ((dm_prim_t)ENUM_DM_HCI_READ_LOCAL_NAME_CFM)
#define DM_HCI_READ_CONN_ACCEPT_TIMEOUT_CFM              ((dm_prim_t)ENUM_DM_HCI_READ_CONN_ACCEPT_TIMEOUT_CFM)
#define DM_HCI_WRITE_CONN_ACCEPT_TIMEOUT_CFM             ((dm_prim_t)ENUM_DM_HCI_WRITE_CONN_ACCEPT_TIMEOUT_CFM)
#define DM_HCI_READ_PAGE_TIMEOUT_CFM                     ((dm_prim_t)ENUM_DM_HCI_READ_PAGE_TIMEOUT_CFM)
#define DM_HCI_WRITE_PAGE_TIMEOUT_CFM                    ((dm_prim_t)ENUM_DM_HCI_WRITE_PAGE_TIMEOUT_CFM)
#define DM_HCI_READ_SCAN_ENABLE_CFM                      ((dm_prim_t)ENUM_DM_HCI_READ_SCAN_ENABLE_CFM)
#define DM_HCI_WRITE_SCAN_ENABLE_CFM                     ((dm_prim_t)ENUM_DM_HCI_WRITE_SCAN_ENABLE_CFM)
#define DM_HCI_READ_PAGESCAN_ACTIVITY_CFM                ((dm_prim_t)ENUM_DM_HCI_READ_PAGESCAN_ACTIVITY_CFM)
#define DM_HCI_WRITE_PAGESCAN_ACTIVITY_CFM               ((dm_prim_t)ENUM_DM_HCI_WRITE_PAGESCAN_ACTIVITY_CFM)
#define DM_HCI_READ_INQUIRYSCAN_ACTIVITY_CFM             ((dm_prim_t)ENUM_DM_HCI_READ_INQUIRYSCAN_ACTIVITY_CFM)
#define DM_HCI_WRITE_INQUIRYSCAN_ACTIVITY_CFM            ((dm_prim_t)ENUM_DM_HCI_WRITE_INQUIRYSCAN_ACTIVITY_CFM)
#define DM_HCI_READ_AUTH_ENABLE_CFM                      ((dm_prim_t)ENUM_DM_HCI_READ_AUTH_ENABLE_CFM)
#define DM_HCI_READ_ENC_MODE_CFM                         ((dm_prim_t)ENUM_DM_HCI_READ_ENC_MODE_CFM)
#define DM_HCI_READ_CLASS_OF_DEVICE_CFM                  ((dm_prim_t)ENUM_DM_HCI_READ_CLASS_OF_DEVICE_CFM)
#define DM_HCI_WRITE_CLASS_OF_DEVICE_CFM                 ((dm_prim_t)ENUM_DM_HCI_WRITE_CLASS_OF_DEVICE_CFM)
#define DM_HCI_READ_VOICE_SETTING_CFM                    ((dm_prim_t)ENUM_DM_HCI_READ_VOICE_SETTING_CFM)
#define DM_HCI_WRITE_VOICE_SETTING_CFM                   ((dm_prim_t)ENUM_DM_HCI_WRITE_VOICE_SETTING_CFM)
#define DM_HCI_READ_AUTO_FLUSH_TIMEOUT_CFM               ((dm_prim_t)ENUM_DM_HCI_READ_AUTO_FLUSH_TIMEOUT_CFM)
#define DM_HCI_WRITE_AUTO_FLUSH_TIMEOUT_CFM              ((dm_prim_t)ENUM_DM_HCI_WRITE_AUTO_FLUSH_TIMEOUT_CFM)
#define DM_HCI_READ_NUM_BCAST_RETXS_CFM                  ((dm_prim_t)ENUM_DM_HCI_READ_NUM_BCAST_RETXS_CFM)
#define DM_HCI_WRITE_NUM_BCAST_RETXS_CFM                 ((dm_prim_t)ENUM_DM_HCI_WRITE_NUM_BCAST_RETXS_CFM)
#define DM_HCI_READ_HOLD_MODE_ACTIVITY_CFM               ((dm_prim_t)ENUM_DM_HCI_READ_HOLD_MODE_ACTIVITY_CFM)
#define DM_HCI_WRITE_HOLD_MODE_ACTIVITY_CFM              ((dm_prim_t)ENUM_DM_HCI_WRITE_HOLD_MODE_ACTIVITY_CFM)
#define DM_HCI_READ_TX_POWER_LEVEL_CFM                   ((dm_prim_t)ENUM_DM_HCI_READ_TX_POWER_LEVEL_CFM)
#define DM_HCI_READ_SCO_FLOW_CON_ENABLE_CFM              ((dm_prim_t)ENUM_DM_HCI_READ_SCO_FLOW_CON_ENABLE_CFM)
#define DM_HCI_WRITE_SCO_FLOW_CON_ENABLE_CFM             ((dm_prim_t)ENUM_DM_HCI_WRITE_SCO_FLOW_CON_ENABLE_CFM)
#define DM_HCI_READ_LINK_SUPERV_TIMEOUT_CFM              ((dm_prim_t)ENUM_DM_HCI_READ_LINK_SUPERV_TIMEOUT_CFM)
#define DM_HCI_WRITE_LINK_SUPERV_TIMEOUT_CFM             ((dm_prim_t)ENUM_DM_HCI_WRITE_LINK_SUPERV_TIMEOUT_CFM)
#define DM_HCI_READ_NUM_SUPPORTED_IAC_CFM                ((dm_prim_t)ENUM_DM_HCI_READ_NUM_SUPPORTED_IAC_CFM)
#define DM_HCI_READ_CURRENT_IAC_LAP_CFM                  ((dm_prim_t)ENUM_DM_HCI_READ_CURRENT_IAC_LAP_CFM)
#define DM_HCI_WRITE_CURRENT_IAC_LAP_CFM                 ((dm_prim_t)ENUM_DM_HCI_WRITE_CURRENT_IAC_LAP_CFM)
#define DM_HCI_READ_PAGESCAN_PERIOD_MODE_CFM             ((dm_prim_t)ENUM_DM_HCI_READ_PAGESCAN_PERIOD_MODE_CFM)
#define DM_HCI_WRITE_PAGESCAN_PERIOD_MODE_CFM            ((dm_prim_t)ENUM_DM_HCI_WRITE_PAGESCAN_PERIOD_MODE_CFM)
#define DM_HCI_READ_PAGESCAN_MODE_CFM                    ((dm_prim_t)ENUM_DM_HCI_READ_PAGESCAN_MODE_CFM)
#define DM_HCI_WRITE_PAGESCAN_MODE_CFM                   ((dm_prim_t)ENUM_DM_HCI_WRITE_PAGESCAN_MODE_CFM)
#define DM_HCI_READ_SECURE_CONNECTIONS_HOST_SUPPORT_CFM  ((dm_prim_t)ENUM_DM_HCI_READ_SECURE_CONNECTIONS_HOST_SUPPORT_CFM)
#define DM_HCI_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT_CFM ((dm_prim_t)ENUM_DM_HCI_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT_CFM)
#define DM_HCI_AUTHENTICATED_PAYLOAD_TIMEOUT_EXPIRED_IND ((dm_prim_t)ENUM_DM_HCI_AUTHENTICATED_PAYLOAD_TIMEOUT_EXPIRED_IND)
#define DM_HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_CFM    ((dm_prim_t)ENUM_DM_HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_CFM)
#define DM_HCI_SET_RESERVED_LT_ADDR_CFM                  ((dm_prim_t) ENUM_DM_HCI_SET_RESERVED_LT_ADDR_CFM)
#define DM_HCI_DELETE_RESERVED_LT_ADDR_CFM               ((dm_prim_t) ENUM_DM_HCI_DELETE_RESERVED_LT_ADDR_CFM)
#define DM_HCI_SET_CSB_DATA_CFM                          ((dm_prim_t) ENUM_DM_HCI_SET_CSB_DATA_CFM)
#define DM_HCI_WRITE_SYNCHRONIZATION_TRAIN_PARAMS_CFM    ((dm_prim_t) ENUM_DM_HCI_WRITE_SYNCHRONIZATION_TRAIN_PARAMS_CFM)
#define DM_HCI_READ_SYNCHRONIZATION_TRAIN_PARAMS_CFM     ((dm_prim_t) ENUM_DM_HCI_READ_SYNCHRONIZATION_TRAIN_PARAMS_CFM)
#define DM_HCI_CONFIGURE_DATA_PATH_CFM                   ((dm_prim_t) ENUM_DM_HCI_CONFIGURE_DATA_PATH_CFM)

/******************************************************************************
   Informational parameters
 *****************************************************************************/
/*-------------------------------------------------------------
Downstream primitives
---------------------------------------------------------------*/
#define DM_HCI_READ_LOCAL_VER_INFO_REQ          ((dm_prim_t) ENUM_DM_HCI_READ_LOCAL_VER_INFO_REQ)
#define DM_HCI_READ_LOCAL_SUPP_FEATURES_REQ     ((dm_prim_t) ENUM_DM_HCI_READ_LOCAL_SUPP_FEATURES_REQ)
#define DM_HCI_READ_COUNTRY_CODE_REQ            ((dm_prim_t) ENUM_DM_HCI_READ_COUNTRY_CODE_REQ)
#define DM_HCI_READ_BD_ADDR_REQ                 ((dm_prim_t) ENUM_DM_HCI_READ_BD_ADDR_REQ)

/*-------------------------------------------------------------
Upstream primitives
---------------------------------------------------------------*/
#define DM_HCI_READ_LOCAL_VER_INFO_CFM          ((dm_prim_t)ENUM_DM_HCI_READ_LOCAL_VER_INFO_CFM)
#define DM_HCI_READ_LOCAL_SUPP_FEATURES_CFM     ((dm_prim_t)ENUM_DM_HCI_READ_LOCAL_SUPP_FEATURES_CFM)
#define DM_HCI_READ_COUNTRY_CODE_CFM            ((dm_prim_t)ENUM_DM_HCI_READ_COUNTRY_CODE_CFM)
#define DM_HCI_READ_BD_ADDR_CFM                 ((dm_prim_t)ENUM_DM_HCI_READ_BD_ADDR_CFM)

/******************************************************************************
   Status parameters
 *****************************************************************************/
/*-------------------------------------------------------------
Downstream primitives
---------------------------------------------------------------*/
#define DM_HCI_READ_FAILED_CONTACT_COUNT_REQ    ((dm_prim_t) ENUM_DM_HCI_READ_FAILED_CONTACT_COUNT_REQ)
#define DM_HCI_RESET_FAILED_CONTACT_COUNT_REQ   ((dm_prim_t) ENUM_DM_HCI_RESET_FAILED_CONTACT_COUNT_REQ)
#define DM_HCI_GET_LINK_QUALITY_REQ             ((dm_prim_t) ENUM_DM_HCI_GET_LINK_QUALITY_REQ)
#define DM_HCI_READ_RSSI_REQ                    ((dm_prim_t) ENUM_DM_HCI_READ_RSSI_REQ)

/*-------------------------------------------------------------
Upstream primitives
---------------------------------------------------------------*/
#define DM_HCI_READ_FAILED_CONTACT_COUNT_CFM    ((dm_prim_t)ENUM_DM_HCI_READ_FAILED_CONTACT_COUNT_CFM)
#define DM_HCI_RESET_FAILED_CONTACT_COUNT_CFM   ((dm_prim_t)ENUM_DM_HCI_RESET_FAILED_CONTACT_COUNT_CFM)
#define DM_HCI_GET_LINK_QUALITY_CFM             ((dm_prim_t)ENUM_DM_HCI_GET_LINK_QUALITY_CFM)
#define DM_HCI_READ_RSSI_CFM                    ((dm_prim_t)ENUM_DM_HCI_READ_RSSI_CFM)

/******************************************************************************
   Testing primitives
 *****************************************************************************/
/*-------------------------------------------------------------
Downstream primitives
---------------------------------------------------------------*/
#define DM_HCI_ENABLE_DUT_MODE_REQ            ((dm_prim_t) ENUM_DM_HCI_ENABLE_DUT_MODE_REQ)

/*-------------------------------------------------------------
Upstream primitives
---------------------------------------------------------------*/
#define DM_HCI_ENABLE_DUT_MODE_CFM ((dm_prim_t)ENUM_DM_HCI_ENABLE_DUT_MODE_CFM)

/***********************************************************************
   ULP primitives
 ***********************************************************************/

/*-------------------------------------------------------------
Downstream primitives
---------------------------------------------------------------*/
#define DM_HCI_ULP_SET_EVENT_MASK_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_SET_EVENT_MASK_REQ)
#define DM_HCI_ULP_READ_LOCAL_SUPPORTED_FEATURES_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_READ_LOCAL_SUPPORTED_FEATURES_REQ)
#define DM_HCI_ULP_SET_ADVERTISING_PARAMETERS_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_SET_ADVERTISING_PARAMETERS_REQ)
#define DM_HCI_ULP_READ_ADVERTISING_CHANNEL_TX_POWER_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_READ_ADVERTISING_CHANNEL_TX_POWER_REQ)
#define DM_HCI_ULP_SET_ADVERTISING_DATA_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_SET_ADVERTISING_DATA_REQ)
#define DM_HCI_ULP_SET_SCAN_RESPONSE_DATA_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_SET_SCAN_RESPONSE_DATA_REQ)
#define DM_HCI_ULP_SET_ADVERTISE_ENABLE_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_SET_ADVERTISE_ENABLE_REQ)
#define DM_HCI_ULP_SET_SCAN_PARAMETERS_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_SET_SCAN_PARAMETERS_REQ)
#define DM_HCI_ULP_SET_SCAN_ENABLE_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_SET_SCAN_ENABLE_REQ)
#define DM_HCI_ULP_CREATE_CONNECTION_CANCEL_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_CREATE_CONNECTION_CANCEL_REQ)
#define DM_HCI_ULP_READ_WHITE_LIST_SIZE_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_READ_WHITE_LIST_SIZE_REQ)
#define DM_HCI_ULP_CLEAR_WHITE_LIST_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_CLEAR_WHITE_LIST_REQ)
#define DM_HCI_ULP_ADD_DEVICE_TO_WHITE_LIST_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_ADD_DEVICE_TO_WHITE_LIST_REQ)
#define DM_HCI_ULP_REMOVE_DEVICE_FROM_WHITE_LIST_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_REMOVE_DEVICE_FROM_WHITE_LIST_REQ)
#define DM_HCI_ULP_SET_HOST_CHANNEL_CLASSIFICATION_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_SET_HOST_CHANNEL_CLASSIFICATION_REQ)
#define DM_HCI_ULP_READ_CHANNEL_MAP_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_READ_CHANNEL_MAP_REQ)
#define DM_HCI_ULP_READ_REMOTE_USED_FEATURES_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_READ_REMOTE_USED_FEATURES_REQ)
#define DM_HCI_ULP_ENCRYPT_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_ENCRYPT_REQ)
#define DM_HCI_ULP_RAND_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_RAND_REQ)
#define DM_HCI_ULP_READ_SUPPORTED_STATES_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_READ_SUPPORTED_STATES_REQ)
#define DM_HCI_ULP_RECEIVER_TEST_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_RECEIVER_TEST_REQ)
#define DM_HCI_ULP_TRANSMITTER_TEST_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_TRANSMITTER_TEST_REQ)
#define DM_HCI_ULP_TEST_END_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_TEST_END_REQ)
#define DM_HCI_ULP_READ_RESOLVING_LIST_SIZE_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_READ_RESOLVING_LIST_SIZE_REQ)
#define DM_HCI_ULP_SET_PRIVACY_MODE_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_SET_PRIVACY_MODE_REQ)
#define DM_HCI_ULP_ENHANCED_RECEIVER_TEST_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_ENHANCED_RECEIVER_TEST_REQ)
#define DM_HCI_ULP_ENHANCED_TRANSMITTER_TEST_REQ ((dm_prim_t)ENUM_DM_HCI_ULP_ENHANCED_TRANSMITTER_TEST_REQ)

/*-------------------------------------------------------------
Upstream primitives
---------------------------------------------------------------*/
#define DM_HCI_ULP_SET_EVENT_MASK_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_SET_EVENT_MASK_CFM)
#define DM_HCI_ULP_READ_LOCAL_SUPPORTED_FEATURES_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_READ_LOCAL_SUPPORTED_FEATURES_CFM)
#define DM_HCI_ULP_SET_ADVERTISING_PARAMETERS_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_SET_ADVERTISING_PARAMETERS_CFM)
#define DM_HCI_ULP_READ_ADVERTISING_CHANNEL_TX_POWER_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_READ_ADVERTISING_CHANNEL_TX_POWER_CFM)
#define DM_HCI_ULP_SET_ADVERTISING_DATA_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_SET_ADVERTISING_DATA_CFM)
#define DM_HCI_ULP_SET_SCAN_RESPONSE_DATA_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_SET_SCAN_RESPONSE_DATA_CFM)
#define DM_HCI_ULP_SET_ADVERTISE_ENABLE_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_SET_ADVERTISE_ENABLE_CFM)
#define DM_HCI_ULP_SET_SCAN_PARAMETERS_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_SET_SCAN_PARAMETERS_CFM)
#define DM_HCI_ULP_SET_SCAN_ENABLE_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_SET_SCAN_ENABLE_CFM)
#define DM_HCI_ULP_CREATE_CONNECTION_CANCEL_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_CREATE_CONNECTION_CANCEL_CFM)
#define DM_HCI_ULP_READ_WHITE_LIST_SIZE_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_READ_WHITE_LIST_SIZE_CFM)
#define DM_HCI_ULP_CLEAR_WHITE_LIST_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_CLEAR_WHITE_LIST_CFM)
#define DM_HCI_ULP_ADD_DEVICE_TO_WHITE_LIST_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_ADD_DEVICE_TO_WHITE_LIST_CFM)
#define DM_HCI_ULP_REMOVE_DEVICE_FROM_WHITE_LIST_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_REMOVE_DEVICE_FROM_WHITE_LIST_CFM)
#define DM_HCI_ULP_SET_HOST_CHANNEL_CLASSIFICATION_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_SET_HOST_CHANNEL_CLASSIFICATION_CFM)
#define DM_HCI_ULP_READ_CHANNEL_MAP_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_READ_CHANNEL_MAP_CFM)
#define DM_HCI_ULP_READ_REMOTE_USED_FEATURES_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_READ_REMOTE_USED_FEATURES_CFM)
#define DM_HCI_ULP_ENCRYPT_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_ENCRYPT_CFM)
#define DM_HCI_ULP_RAND_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_RAND_CFM)
#define DM_HCI_ULP_READ_SUPPORTED_STATES_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_READ_SUPPORTED_STATES_CFM)
#define DM_HCI_ULP_RECEIVER_TEST_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_RECEIVER_TEST_CFM)
#define DM_HCI_ULP_TRANSMITTER_TEST_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_TRANSMITTER_TEST_CFM)
#define DM_HCI_ULP_TEST_END_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_TEST_END_CFM)
#define DM_HCI_ULP_READ_RESOLVING_LIST_SIZE_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_READ_RESOLVING_LIST_SIZE_CFM)
#define DM_HCI_ULP_SET_PRIVACY_MODE_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_SET_PRIVACY_MODE_CFM)
#define DM_HCI_ULP_ENHANCED_RECEIVER_TEST_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_ENHANCED_RECEIVER_TEST_CFM)
#define DM_HCI_ULP_ENHANCED_TRANSMITTER_TEST_CFM ((dm_prim_t)ENUM_DM_HCI_ULP_ENHANCED_TRANSMITTER_TEST_CFM)

#define DM_HCI_ULP_ADVERTISING_REPORT_IND ((dm_prim_t)ENUM_DM_HCI_ULP_ADVERTISING_REPORT_IND)
#define DM_HCI_ULP_CONNECTION_UPDATE_COMPLETE_IND ((dm_prim_t)ENUM_DM_HCI_ULP_CONNECTION_UPDATE_COMPLETE_IND)

/* Isochronus primitives */
#define DM_ISOC_REGISTER_REQ                ((dm_prim_t)(ENUM_DM_ISOC_REGISTER_REQ))
#define DM_ISOC_REGISTER_CFM                ((dm_prim_t)(ENUM_DM_ISOC_REGISTER_CFM))
#define DM_ISOC_CONFIGURE_CIG_REQ           ((dm_prim_t)(ENUM_DM_ISOC_CONFIGURE_CIG_REQ))
#define DM_ISOC_CONFIGURE_CIG_CFM           ((dm_prim_t)(ENUM_DM_ISOC_CONFIGURE_CIG_CFM))
#define DM_ISOC_CONFIGURE_CIG_TEST_REQ      ((dm_prim_t)(ENUM_DM_ISOC_CONFIGURE_CIG_TEST_REQ))
#define DM_ISOC_CONFIGURE_CIG_TEST_CFM      ((dm_prim_t)(ENUM_DM_ISOC_CONFIGURE_CIG_TEST_CFM))
#define DM_ISOC_REMOVE_CIG_REQ              ((dm_prim_t)(ENUM_DM_ISOC_REMOVE_CIG_REQ))
#define DM_ISOC_REMOVE_CIG_CFM              ((dm_prim_t)(ENUM_DM_ISOC_REMOVE_CIG_CFM))
#define DM_ISOC_CIS_CONNECT_REQ             ((dm_prim_t)(ENUM_DM_ISOC_CIS_CONNECT_REQ))
#define DM_ISOC_CIS_CONNECT_IND             ((dm_prim_t)(ENUM_DM_ISOC_CIS_CONNECT_IND))
#define DM_ISOC_CIS_CONNECT_RSP             ((dm_prim_t)(ENUM_DM_ISOC_CIS_CONNECT_RSP))
#define DM_ISOC_CIS_CONNECT_CFM             ((dm_prim_t)(ENUM_DM_ISOC_CIS_CONNECT_CFM))
#define DM_ISOC_CIS_DISCONNECT_REQ          ((dm_prim_t)(ENUM_DM_ISOC_CIS_DISCONNECT_REQ))
#define DM_ISOC_CIS_DISCONNECT_CFM          ((dm_prim_t)(ENUM_DM_ISOC_CIS_DISCONNECT_CFM))
#define DM_ISOC_CIS_DISCONNECT_IND          ((dm_prim_t)(ENUM_DM_ISOC_CIS_DISCONNECT_IND))
#define DM_ISOC_ISO_TRANSMIT_TEST_REQ       ((dm_prim_t)(ENUM_DM_ISOC_ISO_TRANSMIT_TEST_REQ))
#define DM_ISOC_ISO_TRANSMIT_TEST_CFM       ((dm_prim_t)(ENUM_DM_ISOC_ISO_TRANSMIT_TEST_CFM))
#define DM_ISOC_ISO_RECEIVE_TEST_REQ        ((dm_prim_t)(ENUM_DM_ISOC_ISO_RECEIVE_TEST_REQ))
#define DM_ISOC_ISO_RECEIVE_TEST_CFM        ((dm_prim_t)(ENUM_DM_ISOC_ISO_RECEIVE_TEST_CFM))
#define DM_ISOC_ISO_READ_TEST_COUNTERS_REQ  ((dm_prim_t)(ENUM_DM_ISOC_ISO_READ_TEST_COUNTERS_REQ))
#define DM_ISOC_ISO_READ_TEST_COUNTERS_CFM  ((dm_prim_t)(ENUM_DM_ISOC_ISO_READ_TEST_COUNTERS_CFM))
#define DM_ISOC_SETUP_ISO_DATA_PATH_REQ     ((dm_prim_t)(ENUM_DM_ISOC_SETUP_ISO_DATA_PATH_REQ))
#define DM_ISOC_SETUP_ISO_DATA_PATH_CFM     ((dm_prim_t)(ENUM_DM_ISOC_SETUP_ISO_DATA_PATH_CFM))
#define DM_ISOC_REMOVE_ISO_DATA_PATH_REQ    ((dm_prim_t)(ENUM_DM_ISOC_REMOVE_ISO_DATA_PATH_REQ))
#define DM_ISOC_REMOVE_ISO_DATA_PATH_CFM    ((dm_prim_t)(ENUM_DM_ISOC_REMOVE_ISO_DATA_PATH_CFM))
#define DM_ISOC_CREATE_BIG_REQ              ((dm_prim_t)(ENUM_DM_ISOC_CREATE_BIG_REQ))
#define DM_ISOC_CREATE_BIG_CFM              ((dm_prim_t)(ENUM_DM_ISOC_CREATE_BIG_CFM))
#define DM_ISOC_CREATE_BIG_TEST_REQ         ((dm_prim_t)(ENUM_DM_ISOC_CREATE_BIG_TEST_REQ))
#define DM_ISOC_CREATE_BIG_TEST_CFM         ((dm_prim_t)(ENUM_DM_ISOC_CREATE_BIG_TEST_CFM))
#define DM_ISOC_TERMINATE_BIG_REQ           ((dm_prim_t)(ENUM_DM_ISOC_TERMINATE_BIG_REQ))
#define DM_ISOC_TERMINATE_BIG_CFM           ((dm_prim_t)(ENUM_DM_ISOC_TERMINATE_BIG_CFM))
#define DM_ISOC_BIG_CREATE_SYNC_REQ         ((dm_prim_t)(ENUM_DM_ISOC_BIG_CREATE_SYNC_REQ))
#define DM_ISOC_BIG_CREATE_SYNC_CFM         ((dm_prim_t)(ENUM_DM_ISOC_BIG_CREATE_SYNC_CFM))
#define DM_ISOC_BIG_TERMINATE_SYNC_REQ      ((dm_prim_t)(ENUM_DM_ISOC_BIG_TERMINATE_SYNC_REQ))
#define DM_ISOC_BIG_TERMINATE_SYNC_IND      ((dm_prim_t)(ENUM_DM_ISOC_BIG_TERMINATE_SYNC_IND))
#define DM_HCI_ULP_BIGINFO_ADV_REPORT_IND   ((dm_prim_t)(ENUM_DM_HCI_ULP_BIGINFO_ADV_REPORT_IND))
#define DM_ISOC_READ_ISO_LINK_QUALITY_REQ   ((dm_prim_t)(ENUM_DM_ISOC_READ_ISO_LINK_QUALITY_REQ))
#define DM_ISOC_READ_ISO_LINK_QUALITY_CFM   ((dm_prim_t)(ENUM_DM_ISOC_READ_ISO_LINK_QUALITY_CFM))
#define DM_ISOC_BROADCAST_DEVICE_SECURITY_REQ ((dm_prim_t)(ENUM_DM_ISOC_BROADCAST_DEVICE_SECURITY_REQ))
#define DM_ISOC_BROADCAST_DEVICE_SECURITY_CFM ((dm_prim_t)(ENUM_DM_ISOC_BROADCAST_DEVICE_SECURITY_CFM))

#define DM_HCI_ULP_SET_DEFAULT_SUBRATE_REQ  ((dm_prim_t)(ENUM_DM_HCI_ULP_SET_DEFAULT_SUBRATE_REQ))
#define DM_HCI_ULP_SET_DEFAULT_SUBRATE_CFM  ((dm_prim_t)(ENUM_DM_HCI_ULP_SET_DEFAULT_SUBRATE_CFM))
#define DM_HCI_ULP_SUBRATE_CHANGE_REQ       ((dm_prim_t)(ENUM_DM_HCI_ULP_SUBRATE_CHANGE_REQ))
#define DM_HCI_ULP_SUBRATE_CHANGE_CFM       ((dm_prim_t)(ENUM_DM_HCI_ULP_SUBRATE_CHANGE_CFM))
#define DM_HCI_ULP_SUBRATE_CHANGE_IND       ((dm_prim_t)ENUM_DM_HCI_ULP_SUBRATE_CHANGE_IND)

/* end of #define of primitives */

typedef uint16_t                amp_link_id_t;

/* primitive type for dm */
typedef uint16_t                 dm_prim_t;

/* BLE connection parameters */
typedef struct
{
    uint16_t  conn_interval;
    uint16_t  conn_latency;
    uint16_t  supervision_timeout;
    uint8_t   clock_accuracy;

}DM_ACL_BLE_CONN_PARAMS_T;


/*------------------------------------------------------------------------
 *
 *      REGISTER PRIMITIVES
 *
 *-----------------------------------------------------------------------*/

/* Note1:

        A value of 0 in the 'status' field of returned primitives indicates
        success. All other values indicate failure.
        The error codes are defined here:
        BLUETOOTH CORE SPECIFICATION Version 5.2 | Vol 1, Part F
*/

 /*----------------------------------------------------------------------------*
 * PURPOSE
 *      Standard command complete
 *
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* Success or failure - See Note1 */
} DM_HCI_STANDARD_COMMAND_CFM_T;/* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* Success or failure - See Note1 */
    BD_ADDR_T           bd_addr;            /* Bluetooth address */
} DM_HCI_BD_ADDR_COMMAND_CFM_T;/* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */


typedef struct
{
    dm_prim_t               type;          /* Prim ID */
    phandle_t               phandle;       /* destination phandle */
    uint8_t                 status;        /* Success or failure - See Note1 */
    TYPED_BD_ADDR_T         addrt;         /* Bluetooth address and type */
} DM_HCI_TYPED_BD_ADDR_COMMAND_CFM_T;/* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */


typedef struct
{
    dm_prim_t               type;          /* Prim ID */
    phandle_t               phandle;       /* destination phandle */
    uint8_t                 status;        /* Success or failure - See Note1 */
    TP_BD_ADDR_T            tp_addrt;      /* Typed bluetooth address
                                              and physical transport */
} DM_HCI_TYPED_BD_ADDR_PT_COMMAND_CFM_T;/* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */


typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    BD_ADDR_T           bd_addr;            /* Bluetooth address */
} DM_COMMON_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Register request to AM Interface, registering a destination phandle
 *      for upstream application primitives.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;           /* Always DM_AM_REGISTER_REQ */
    phandle_t               phandle;        /* protocol handle */
    uint16_t                flags;          /* Reserved - set to 0 */
} DM_AM_REGISTER_REQ_T;

typedef struct
{
    dm_prim_t               type;           /* Always DM_AM_REGISTER_WRONG_API_REQ */
    phandle_t               phandle;        /* protocol handle */
} DM_AM_REGISTER_WRONG_API_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Confirmation that the registration request has been received.
 *
 *  RETURNS
 *      phandle specified in DM_AM_REGISTER_REQ.
 *      Bluestack version. MSB is major version, LSB is minor version.
 *      Bluestack patchlevel. This is incremented for every release
 *      with a given Bluestack version number and reset to zero for new
 *      Bluestack version numbers.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;           /* Always DM_AM_REGISTER_CFM */
    phandle_t               phandle;        /* destination phandle */
    uint16_t                version;        /* Bluestack version */
    uint16_t                patch_level;    /* Bluestack patch level */
} DM_AM_REGISTER_CFM_T;

typedef struct
{
    dm_prim_t               type;     /* Always DM_AM_REGISTER_WRONG_API_CFM */
    phandle_t               phandle;  /* destination phandle */
} DM_AM_REGISTER_WRONG_API_CFM_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *      Set Bluetooth version. On successful completion, status will
 *      be set to HCI_SUCCESS == 0 and version will be set to the
 *      BT version requested. On unsuccessful completion, status will
 *      be set to an HCI error code and version will be set to the
 *      current version.
 *
 *      You can use this command to read the current BT version by
 *      setting version to BT_VERSION_CURRENT in the command primitive.
 *      (In this case a failure indication in the status parameter would
 *      be unusual and would indicate that the current version settings
 *      are no longer supported by the device.)
 *---------------------------------------------------------------------------*/

#define BT_VERSION_CURRENT          0x00
#define BT_VERSION_2p0              0x01
#define BT_VERSION_2p1              0x02
#define BT_VERSION_3p0              0x03
#define BT_VERSION_4p0              0x04
#define BT_VERSION_4p1              0x05
#define BT_VERSION_4p2              0x06
#define BT_VERSION_5p0              0x07
#define BT_VERSION_5p1              0x08
#define BT_VERSION_5p2              0x09
#define BT_VERSION_5p3              0x0A
#define BT_VERSION_5p4              0x0B
#define BT_VERSION_6p0              0x0C

#define BT_VERSION_MAX              BT_VERSION_6p0


typedef struct
{
    dm_prim_t               type;           /* Always DM_SET_BT_VERSION_REQ */
    uint8_t                 version;        /* Requested version */
} DM_SET_BT_VERSION_REQ_T;

typedef struct
{
    dm_prim_t               type;           /* Always DM_SET_BT_VERSION_CFM */
    phandle_t               phandle;        /* destination phandle */
    uint8_t                 version;        /* Requested version if success, */
    uint8_t                 status;         /* or current version if failure */
} DM_SET_BT_VERSION_CFM_T;

/*------------------------------------------------------------------------
 *  PURPOSE
 *  Indication sent to phandle registered with DM_AM_REGISTER_REQ when
 *  Bluestack receives a message to which it cannot respond in the
 *  usual fashion. This might be because the message is not recognised
 *  or because there is no obvious phandle to use for the reply. In
 *  these cases, Bluestack will send DM_BAD_MESSAGE_IND.
 *-----------------------------------------------------------------------*/

/* Reasons */
#define DM_BAD_MESSAGE_NO_PHANDLE       ((uint16_t)0x0001)
#define DM_BAD_MESSAGE_NOT_RECOGNISED   ((uint16_t)0x0002)

typedef struct
{
    dm_prim_t               type;           /* Always DM_BAD_MESSAGE_IND */
    phandle_t               phandle;        /* destination phandle */
    uint16_t                reason;         /* What went wrong */
    uint8_t                 protocol;       /* L2CAP_PRIM/RFCOMM_PRIM/etc */
    uint16_t                request_type;   /* Enumerated type within protocol*/
    uint16_t                message_length; /* Length of returned message */
    uint8_t                 *message;       /* Returned message */
} DM_BAD_MESSAGE_IND_T;

/*---------------------------------------------------------------------------*
 *  Provides an API to allow an application to able to specify the connection interval,
 *  slave latency, etc, that the local device uses when creating connections in the central role
 *
 *  RETURNS
 *     A CFM
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t type;                 /* DM_SET_BLE_CONNECTION_PARAMETERS_REQ */
    uint16_t scan_interval;         /* These six parameters correspond to */
    uint16_t scan_window;           /* those in HCI_ULP_CREATE_CONNECTION_T */
    uint16_t conn_interval_min;     /* and are used to fill that primitive */
    uint16_t conn_interval_max;     /* when it is created. If they are not */
    uint16_t conn_latency;          /* set explicitly here then the Device */
    uint16_t supervision_timeout;   /* Manager will choose defaults. */
    uint16_t conn_attempt_timeout;  /* Equivalent of Page Timeout in BR/EDR */
    uint16_t conn_latency_max;        /* The 3 parameters are used to define the conditions */
    uint16_t supervision_timeout_min; /* to accept a  */
    uint16_t supervision_timeout_max; /* L2CA_CONNECTION_PAR_UPDATE_REQ_T*/
    uint8_t own_address_type;         /* Own Address Type used in LE connection
                                         request by central device*/
} DM_SET_BLE_CONNECTION_PARAMETERS_REQ_T;


typedef struct
{
    dm_prim_t type;
    phandle_t phandle;
    uint8_t status;
} DM_SET_BLE_CONNECTION_PARAMETERS_CFM_T;


/*------------------------------------------------------------------------
 *
 *      SYNCHRONOUS CONNECTION INTERFACE PRIMITIVES
 *      These primitives are all sent to the DM_IFACEQUEUE input queue.
 *
 *-----------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t               type;
    phandle_t               phandle;
    context_t               pv_cbarg;
    hci_connection_handle_t handle;
    uint8_t                 status_or_reason;
} DM_SYNC_UPSTREAM_WITH_HANDLE_COMMON_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef struct
{
    dm_prim_t                   type;
    hci_connection_handle_t     handle;
} DM_SYNC_DOWNSTREAM_WITH_HANDLE_COMMON_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef struct
{

    dm_prim_t               type;           /* Always DM_SYNC_REGISTER_REQ */
    phandle_t               phandle;        /* protocol handle */

    /* Opaque argument to be returned in all upstream SCO primitives, can be
     * used by the destination task for discrimination purposes.
     * The Bluelab connection library uses this to store the application
     * task and routes messages accordingly.
     */
    context_t               pv_cbarg;
    uint16_t                flags;

    /* Stream sizes - only applicable if stream flag set */
    STREAM_BUFFER_SIZES_T   streams;
} DM_SYNC_REGISTER_REQ_T;

typedef struct
{
    dm_prim_t               type;
    phandle_t               phandle;
    context_t               pv_cbarg;
} DM_SYNC_REGISTER_CFM_T;

typedef struct
{
    dm_prim_t               type;           /* Always DM_SYNC_UNREGISTER_REQ */
    phandle_t               phandle;        /* client phandle */
    context_t               pv_cbarg;
} DM_SYNC_UNREGISTER_REQ_T;

#define DM_SYNC_UNREGISTER_SUCCESS          ((uint8_t)0)
#define DM_SYNC_UNREGISTER_NOT_FOUND        ((uint8_t)1)
#define DM_SYNC_UNREGISTER_BUSY             ((uint8_t)2)
typedef struct
{
    dm_prim_t               type;           /* Always DM_SYNC_UNREGISTER_CFM */
    phandle_t               phandle;        /* client phandle */
    context_t               pv_cbarg;
    uint8_t                 status;
} DM_SYNC_UNREGISTER_CFM_T;

typedef struct
{
    uint16_t                max_latency;
    uint16_t                retx_effort;
    hci_pkt_type_t          packet_type;    /* Set to zero for default */
    uint16_t                voice_settings;
    uint32_t                tx_bdw;
    uint32_t                rx_bdw;
} DM_SYNC_CONFIG_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef union
{
    DM_SYNC_CONFIG_T    *config;        /* Pointer to config structure. */
    uint16_t            *conftab;       /* Not currently used. */
} DM_SYNC_CONFIG_UNION_T;

typedef struct
{
    dm_prim_t               type;           /* Always DM_SYNC_CONNECT_REQ */
    phandle_t               phandle;        /* client phandle */
    context_t               pv_cbarg;
    BD_ADDR_T               bd_addr;        /* Bluetooth device address */
    uint16_t                length;         /* Reserved. Shall be set to zero.*/
    DM_SYNC_CONFIG_UNION_T  u;
} DM_SYNC_CONNECT_REQ_T;

typedef struct
{
    dm_prim_t               type;           /* Always DM_SYNC_CONNECT_CFM */
    phandle_t               phandle;        /* client phandle */
    context_t               pv_cbarg;
    hci_connection_handle_t handle;         /* HCI Connection Handle */
    uint8_t                 status;         /* Success or failure - See Note1 */
    BD_ADDR_T               bd_addr;        /* Bluetooth device address */
    uint8_t                 link_type;
    uint8_t                 tx_interval;
    uint8_t                 wesco;
    uint16_t                rx_packet_length;
    uint16_t                tx_packet_length;
    uint8_t                 air_mode;
} DM_SYNC_CONNECT_COMPLETE_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */
typedef DM_SYNC_CONNECT_COMPLETE_T DM_SYNC_CONNECT_CFM_T;
typedef DM_SYNC_CONNECT_COMPLETE_T DM_SYNC_CONNECT_COMPLETE_IND_T;

typedef struct
{
    dm_prim_t               type;           /* Always DM_SYNC_CONNECT_IND */
    phandle_t               phandle;        /* client phandle */
    context_t               pv_cbarg;
    BD_ADDR_T               bd_addr;        /* Bluetooth device address */
    uint8_t                 link_type;      /* HCI_LINK_TYPE_SCO/ESCO */
    uint24_t                dev_class;
} DM_SYNC_CONNECT_IND_T;

typedef struct
{
    dm_prim_t               type;           /* Always DM_SYNC_CONNECT_RSP */
    BD_ADDR_T               bd_addr;        /* Bluetooth device address */
    uint8_t                 response;       /* HCI_SUCCESS or appropriate HCI_ERROR_ code */
    DM_SYNC_CONFIG_T        config;
} DM_SYNC_CONNECT_RSP_T;

/* If you just want to change the packet type then set max_latency
   and retx_effort to 0. This is the equivalent of sending
   DM_HCI_CHANGE_CONN_PKT_TYPE_REQ. */
typedef struct
{
    dm_prim_t                   type;       /* Always DM_SYNC_RENEGOTIATE_REQ */
    hci_connection_handle_t     handle;     /* HCI Connection Handle */
    uint16_t                    length;     /* Reserved. Shall be set to zero.*/
    DM_SYNC_CONFIG_UNION_T      u;
} DM_SYNC_RENEGOTIATE_REQ_T;

typedef struct
{
    dm_prim_t                   type;       /* Always DM_SYNC_RENEGOTIATE_IND */
    phandle_t                   phandle;    /* destination phandle */
    context_t                   pv_cbarg;
    hci_connection_handle_t     handle;     /* HCI Connection Handle */
    hci_return_t                status;

    /* If the following parameters are all 0 then they should be ignored. */
    uint8_t                     tx_interval;
    uint8_t                     wesco;
    uint16_t                    rx_packet_length;
    uint16_t                    tx_packet_length;
} DM_SYNC_RENEGOTIATE_INDCFM_T; /* autogen_makefile_ignore_this */

typedef DM_SYNC_RENEGOTIATE_INDCFM_T DM_SYNC_RENEGOTIATE_IND_T;
typedef DM_SYNC_RENEGOTIATE_INDCFM_T DM_SYNC_RENEGOTIATE_CFM_T;

typedef struct
{
    dm_prim_t                   type;           /* Always DM_SYNC_DISCONNECT_REQ */
    hci_connection_handle_t     handle;         /* HCI Connection Handle */
    hci_reason_t                reason;         /* reason for disconnection */
} DM_SYNC_DISCONNECT_REQ_T;

/* List of generic status codes from  Device Manager */
#define DM_STATUS_BASE                         ((hci_reason_t)0xD0)

#define DM_STATUS_SCO_LINK_TRANSFERRED         ((hci_reason_t)(DM_STATUS_BASE))

/* Note: DM_SYNC_DISCONNECT_IND would be recieved at the new Secondary during handover
   with reason=DM_SCO_LINK_TRANSFERRED for the eSCO non-mirrored link */
typedef struct
{
    dm_prim_t                   type;           /* Always DM_SYNC_DISCONNECT_IND */
    phandle_t                   phandle;        /* destination phandle */
    context_t                   pv_cbarg;
    hci_connection_handle_t     handle;         /* HCI Connection Handle */
    hci_reason_t                reason;         /* reason for disconnection */
    BD_ADDR_T                   bd_addr;        /* Bluetooth device address */
} DM_SYNC_DISCONNECT_IND_T;

typedef struct
{
    dm_prim_t                   type;           /* Always DM_SYNC_DISCONNECT_CFM */
    phandle_t                   phandle;        /* destination phandle */
    context_t                   pv_cbarg;
    hci_connection_handle_t     handle;         /* HCI Connection Handle */
    uint8_t                     status;         /* Success or failure - See Note1 */
    BD_ADDR_T                   bd_addr;        /* Bluetooth device address */
} DM_SYNC_DISCONNECT_CFM_T;

/*----------------------------------------------------------------------------*
 *
 *  SECURITY MANAGEMENT INTERFACE
 *
 *  Downstream primitives are sent to the DM_IFACEQUEUE, upstream primitives
 *  are sent either to the registered AM queue (see DM_AM_REGISTER_REQ), or to
 *  the queue of the protocol layer requesting access (for DM_SM_ACCESS_REQ).
 *  There is a private L2CAP/SM interface for controlling security of received
 *  connectionless packets.
 *
 *----------------------------------------------------------------------------*/

typedef uint8_t dm_security_mode_t;
#define SEC_MODE0_OFF                   ((dm_security_mode_t) 0x00)
#define SEC_MODE1_NON_SECURE            ((dm_security_mode_t) 0x01)
#define SEC_MODE2_SERVICE               ((dm_security_mode_t) 0x02)
#define SEC_MODE3_LINK                  ((dm_security_mode_t) 0x03)
#define SEC_MODE4_SSP                   ((dm_security_mode_t) 0x04)
/*
   SEC_MODE2a_DEVICE is a custom security mode that authenticates on a per
   device basis using the Security Manager's device database.
   On starting a new service (incoming and outgoing), the device will be
   authenticated unless it is marked as 'trusted' in the device database
   (see DM_SM_ADD_DEVICE_REQ).
*/
#define SEC_MODE2a_DEVICE               ((dm_security_mode_t) 0x80)

/* Security level settings
 *
 * SECL_(IN|OUT)_AUTHORISATION (both mode 4 and legacy)
 * Results in a DM_SM_AUTHORISE_IND on a connection attempt from a
 * device that is not marked as 'trusted' in the device database.
 *
 * SECL_(IN|OUT)_AUTHENTICATION (legacy)
 * For connections where at least one of the devices is not in mode 4
 * (i.e. it's a legacy device) then the legacy pairing procedure
 * should be used. The users may have to enter PINs.
 *
 * SECL_(IN|OUT)_ENCRYPTION (legacy)
 * This setting indicates that the link should be encrypted after legacy
 * authentication.
 *
 * SECL4_(IN|OUT)_SSP (mode 4)
 * For connections where both devices are in mode 4, Secure Simple Pairing
 * is used to generate a shared link key and the link is then encrypted. Only
 * SDP is allowed not to have these bits set. All other services must set
 * them to achieve compliance.
 *
 * SECL4_(IN|OUT)_MITM (mode 4)
 * For connections where both devices are in mode 4, Secure Simple Pairing
 * is used to generate a shared authenticated link key and the link is
 * then encrypted. If you set this then you should also set
 * SECL4_(IN|OUT)_SSP as it is implied.
 *
 * SECL4_(IN|OUT)_NO_LEGACY
 * Don't support legacy security procedures. This is a mode4-only setting.
 * By setting this, you are preventing the device from using legacy pairing
 * procedures to authenticate with remote devices that do not support
 * simple pairing. If you set this then the device will be
 * incapable of pairing using legacy procedures and so will reject all
 * connection attempts with legacy devices where security is required.
 * If you set this then you may severely reduce interoperability.
 *
 */

typedef uint16_t dm_security_level_t;

/* BR/EDR security levels */
#define SECL_NONE                           ((dm_security_level_t) 0x0000)
#define SECL_IN_AUTHORISATION               ((dm_security_level_t) 0x0001)
#define SECL_IN_AUTHENTICATION              ((dm_security_level_t) 0x0002)
#define SECL_IN_ENCRYPTION                  ((dm_security_level_t) 0x0004)
#define SECL_OUT_AUTHORISATION              ((dm_security_level_t) 0x0008)
#define SECL_OUT_AUTHENTICATION             ((dm_security_level_t) 0x0010)
#define SECL_OUT_ENCRYPTION                 ((dm_security_level_t) 0x0020)

#define SECL4_IN_SSP                        ((dm_security_level_t) 0x0100)
#define SECL4_IN_MITM                       ((dm_security_level_t) 0x0200)
#define SECL4_IN_NO_LEGACY                  ((dm_security_level_t) 0x0400)
#define SECL4_OUT_SSP                       ((dm_security_level_t) 0x0800)
#define SECL4_OUT_MITM                      ((dm_security_level_t) 0x1000)
#define SECL4_OUT_NO_LEGACY                 ((dm_security_level_t) 0x2000)

#define SECL4_IN_P256_ONLY                  ((dm_security_level_t) 0x4000)
#define SECL4_OUT_P256_ONLY                 ((dm_security_level_t) 0x8000)

/*
 * BR/EDR Security Levels defined in Vol 3, Part C, Section 5.2.2.5 of BT2.1 
 * Spec
 *
 * N.B. These only affect authentication and encryption. Authorisation is
 *      separate.
 */
/* No security - permitted for SDP only */
#define SECL4_IN_LEVEL_0    SECL_NONE
#define SECL4_OUT_LEVEL_0   SECL_NONE
#define SECL4_LEVEL_0       (SECL4_IN_LEVEL_0 | SECL4_OUT_LEVEL_0)
/* Low security */
#define SECL4_IN_LEVEL_1    SECL4_IN_SSP
#define SECL4_OUT_LEVEL_1   SECL4_OUT_SSP
#define SECL4_LEVEL_1       (SECL4_IN_LEVEL_1 | SECL4_OUT_LEVEL_1)
/* Medium security */
#define SECL4_IN_LEVEL_2    (SECL4_IN_SSP | SECL_IN_AUTHENTICATION \
                                                        | SECL_IN_ENCRYPTION)
#define SECL4_OUT_LEVEL_2   (SECL4_OUT_SSP | SECL_OUT_AUTHENTICATION \
                                                        | SECL_OUT_ENCRYPTION)
#define SECL4_LEVEL_2       (SECL4_IN_LEVEL_2 | SECL4_OUT_LEVEL_2)
/* High security */
#define SECL4_IN_LEVEL_3    (SECL4_IN_SSP | SECL4_IN_MITM \
                               | SECL_IN_AUTHENTICATION | SECL_IN_ENCRYPTION)
#define SECL4_OUT_LEVEL_3    (SECL4_OUT_SSP | SECL4_OUT_MITM \
                               | SECL_OUT_AUTHENTICATION | SECL_OUT_ENCRYPTION)
#define SECL4_LEVEL_3       (SECL4_IN_LEVEL_3 | SECL4_OUT_LEVEL_3)

/* Secure connections security level 4 - P256-based algorithms only */
#define SECL4_IN_LEVEL_4    (SECL4_IN_SSP | SECL4_IN_MITM \
                               | SECL_IN_AUTHENTICATION | SECL_IN_ENCRYPTION \
                               | SECL4_IN_NO_LEGACY | SECL4_IN_P256_ONLY)
#define SECL4_OUT_LEVEL_4    (SECL4_OUT_SSP | SECL4_OUT_MITM \
                               | SECL_OUT_AUTHENTICATION | SECL_OUT_ENCRYPTION \
                               | SECL4_OUT_NO_LEGACY | SECL4_OUT_P256_ONLY)
#define SECL4_LEVEL_4       (SECL4_IN_LEVEL_4 | SECL4_OUT_LEVEL_4)
/*
 * Security level combinations useful internally
 */
/* Incoming security settings */
#define SECL_IN    (SECL_IN_AUTHORISATION | SECL_IN_AUTHENTICATION      \
        | SECL_IN_ENCRYPTION | SECL4_IN_SSP | SECL4_IN_MITM \
        | SECL4_IN_NO_LEGACY | SECL4_IN_P256_ONLY)

/* Outgoing security settings */
#define SECL_OUT   (SECL_OUT_AUTHORISATION | SECL_OUT_AUTHENTICATION    \
        | SECL_OUT_ENCRYPTION | SECL4_OUT_SSP | SECL4_OUT_MITM          \
        | SECL4_OUT_NO_LEGACY | SECL4_OUT_P256_ONLY)

/* Authorisation required (either in or out) */
#define SECL_AUTHORISATION (SECL_IN_AUTHORISATION | SECL_OUT_AUTHORISATION)

/* Authentication required (legacy) */
#define SECL_AUTHENTICATION (SECL_IN_AUTHENTICATION \
        | SECL_OUT_AUTHENTICATION | SECL_IN_ENCRYPTION | SECL_OUT_ENCRYPTION)

/* Encryption required (legacy) */
#define SECL_ENCRYPTION (SECL_IN_ENCRYPTION | SECL_OUT_ENCRYPTION)

/* Simple Secure Pairing required (either in or out) */
#define SECL4_SSP (SECL4_IN_SSP | SECL4_OUT_SSP | SECL4_IN_MITM \
                                                            | SECL4_OUT_MITM)

/* MITM protection required in mode 4 (either in or out) */
#define SECL4_MITM (SECL4_IN_MITM | SECL4_OUT_MITM)

/* Legacy pairing prohibited in mode 4 (either in or out) */
#define SECL4_NO_LEGACY (SECL4_IN_NO_LEGACY | SECL4_OUT_NO_LEGACY)

/* Mask of legacy mode settings */
#define SECL_MODE_LEGACY                ((dm_security_level_t) 0x007F)

/* P256 security required in mode 4 (either in or out) */
#define SECL4_P256_ONLY (SECL4_IN_P256_ONLY | SECL4_OUT_P256_ONLY)

/* The default security level, applied in security modes 2, 3 and 4 when no
 * specific security level has been registered for a service. This is set to
 * require authentication and encryption of both incoming and outgoing
 * connections. It also requires authorisation of incoming connections.
 * It may be overridden at run-time using the DM_SET_DEFAULT_SECURITY_REQ
 * primitive.
 */
#define SECL_DEFAULT (SECL_IN_AUTHORISATION | SECL4_LEVEL_2)

/* LE Service Security Requirements 
 *
 * Following are basic security requirements defined for LE services.
 * Security levels of services are defined using combination of these 
 * requirements.
 * Since BR/EDR and LE security levels cannot be mapped one on one, 
 * these defined values shall be used for LE services in DM_SM_REGISTER_REQ_T
 * 
 */
#define SEC_LE_NONE                 ((dm_security_level_t) 0x0000)
#define SEC_LE_IN_ENCRYPTION        ((dm_security_level_t) 0x0001)
#define SEC_LE_IN_AUTHORISATION     ((dm_security_level_t) 0x0002)
#define SEC_LE_OUT_ENCRYPTION       ((dm_security_level_t) 0x0004)
#define SEC_LE_OUT_AUTHORISATION    ((dm_security_level_t) 0x0008)
#define SEC_LE_ENCRYPTION    (SEC_LE_IN_ENCRYPTION | SEC_LE_OUT_ENCRYPTION)
#define SEC_LE_AUTHORISATION (SEC_LE_IN_AUTHORISATION | SEC_LE_OUT_AUTHORISATION)

/* LE Authentication levels */
#define SEC_LE_MITM                 ((dm_security_level_t) 0x0100)
#define SEC_LE_SECURE_CONNECTION    ((dm_security_level_t) 0x0200)

#define SEC_LE_128_BIT_ENC_KEY      ((dm_security_level_t) 0x1000)

/* LE security levels 
 * These security levels are mapped to LE GAP security levels from specification
 * Ref : Version 4.2 [Vol 3, Part C] Sec 10.2.1
 *
 * When device is put to SC only mode, all the services security requirement 
 * will considered to be SEC_LE_MODE1_LEVEL_4 while evaluating the security,
 * except for services which requires no encryption(level 1).
 *
 * Important note : It is recommended that applictions use these security
 * levels to avoid interoperability issues unless services has very specific 
 * security requirements which cannot be mapped to GAP security level.
 */
#define SEC_LE_MODE1_LEVEL_1 (SEC_LE_NONE)
#define SEC_LE_MODE1_LEVEL_2 (SEC_LE_ENCRYPTION)
#define SEC_LE_MODE1_LEVEL_3 (SEC_LE_MITM | SEC_LE_MODE1_LEVEL_2)
#define SEC_LE_MODE1_LEVEL_4 (SEC_LE_SECURE_CONNECTION | SEC_LE_128_BIT_ENC_KEY | \
                              SEC_LE_MODE1_LEVEL_3)

/* Custom security requirements, which cannot be mapped to GAP security level. 
 * Since there is no equivalent GAP security requirement it recommended to use
 * these requirements with caution to avoid iop problems */

/* SEC_LE_NO_LEGACY ensures that service will only be connected with remote
 * devices which are paired using LESC pairing */
#define SEC_LE_NO_LEGACY             (SEC_LE_SECURE_CONNECTION)

/* List of error codes related to LE service security */
/* Application on receiving DM_GAP_LE_ERR_INSUFF_AUTHENTICATION error code
 * shall initiate (BT core specification 6.0 and later) a new pairing procedure
 * if device supports authenticated pairing IO capabilities. */
#define DM_GAP_LE_ERROR_BASE                  ((uint8_t)0xE0)

#define DM_GAP_LE_ERR_INSUFF_AUTHENTICATION   ((uint8_t)(DM_GAP_LE_ERROR_BASE))
#define DM_GAP_LE_ERR_INSUFF_ENCRYPTION       ((uint8_t)(DM_GAP_LE_ERROR_BASE + 1))
#define DM_GAP_LE_ERR_INSUFF_KEY_SIZE         ((uint8_t)(DM_GAP_LE_ERROR_BASE + 2))
#define DM_GAP_LE_ERR_INSUFF_AUTHORIZATION    ((uint8_t)(DM_GAP_LE_ERROR_BASE + 3))

/* List of error codes related to L2CAP ECBFC for BR/EDR */
#define DM_GAP_ERR_INSUFF_AUTHORIZATION       DM_GAP_LE_ERR_INSUFF_AUTHORIZATION
#define DM_GAP_ERR_INSUFF_ENCRYPTION          DM_GAP_LE_ERR_INSUFF_ENCRYPTION

typedef struct
{
    DM_SM_SERVICE_T service;
    TYPED_BD_ADDR_T addrt;
} DM_CONNECTION_T; /* autogen_makefile_ignore_this */

typedef struct
{
    DM_CONNECTION_T connection;
    bool_t incoming;
} DM_CONNECTION_SETUP_T; /* autogen_makefile_ignore_this */

/* Standard security protocol identifiers provided by Bluestack. Higher
 * multiplexing protocols must define their own identifiers, from the range
 * SEC_PROTOCOL_USER and above.
 */
#define SEC_PROTOCOL_NONE               ((dm_protocol_id_t) 0x0000)
#define SEC_PROTOCOL_SM_BONDING         ((dm_protocol_id_t) 0x0001)
#define SEC_PROTOCOL_L2CAP              ((dm_protocol_id_t) 0x0002)
#define SEC_PROTOCOL_RFCOMM             ((dm_protocol_id_t) 0x0003)
#define SEC_PROTOCOL_LE_L2CAP           ((dm_protocol_id_t) 0x0004)

/* Protocol modifier bit for internal use only. This will only be used
   by RFCOMM when passing its security requirements through L2CAP. It
   has been found that this causes issues with legacy timeout problems.
   Setting this bit in the security protocol id passed to the security
   manager in a DM_SM_ACCESS_REQ will cause it not to enforce legacy
   security. See B-98570. */
#define SEC_PROTOCOL_MODIFY_SSP_ONLY    ((dm_protocol_id_t) 0x4000)

/* Higher layers base their protocol IDs from here */
#define SEC_PROTOCOL_USER               ((dm_protocol_id_t) 0x8000)

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Registers the security requirements for access to a service or a
 *      multiplexing protocol layer when the Security Manager is in security
 *      mode 2 or 3. The registered security level is applied to all incoming
 *      connections on the specified 'channel', and optionally to all outgoing
 *      connections on that channel if 'outgoing_ok' is TRUE.
 *
 *      It does not always make sense to apply security to outgoing connections,
 *      for example a local RFCOMM server channel is only valid for incoming
 *      connections. An L2CAP PSM, however, may be valid in both directions.
 *      Therefore use the 'outgoing_ok' flag to specify whether security
 *      should be applied to outgoing connections as well as incoming.
 *      When the local and remote L2CAP PSMs are different, the local PSM should
 *      be passed to the Security Manager.  For outgoing connections where the
 *      channel may be different for each remote device, security requirements
 *      may be registered using the DM_SM_REGISTER_OUTGOING_REQ primitive.
 * 
 *      LE services can register the security levels required for the service 
 *      to operate using the same API, since the GAP security levels of BR/EDR 
 *      and LE cannot be mapped one to one, new set of values are defined for
 *      security_level to be used in registration for LE services,can be 
 *      referred under "LE Service Security Requirements" section above.
 * 
 *      NOTE
 *          The Security Manager enforces a default security level in modes 2,
 *          3 and 4 given by the SECL_DEFAULT definition. Any access request
 *          for which there is no registered security level will be subject to
 *          the default security. Therefore it is recommended that certain
 *          services and protocols are always registered with no security,
 *          for example, SDP and RFCOMM. In Security mode 4, no service, other
 *          than SDP, should be registered with no security.
 *
 *          If 'channel' is set to 0 then the security manager will choose
 *          a channel itself. It starts from 0xFFFF and works its way down
 *          until it finds the first unused channel for the protocol in
 *          question. This is currently only used for profiles that are
 *          RFCOMM clients but not servers.
 * 
 *          LE has only 1 security mode which can be used by services, as of now
 *          there is no way applications can set default security mode and 
 *          security levels.
 *
 *      Some security examples are presented:
 *
 *      Eg 1 - A TCS Terminal registers with 'protocol_id' = SEC_PROTOCOL_L2CAP,
 *      'channel' = 7 (cordless telephony PSM), and 'outgoing_ok' = TRUE. Then
 *      L2CAP will request access from the Security Manager for all connections,
 *      incoming and outgoing, on PSM 7.
 *
 *      Eg 2 - A headset profile might register with 'protocol_id' =
 *      SEC_PROTOCOL_RFCOMM, 'channel' = the RFCOMM server channel number of the
 *      headset service, and 'outgoing_ok' = FALSE. Then RFCOMM will request
 *      access from the Security Manager for all incoming connections on that
 *      server channel. Access requests for outgoing connections will be
 *      subjected to the default security level.
 *
 *      Eg 3 - As for (Eg 2), but whenever the profile makes an outgoing
 *      connection to an Audio Gateway it first performs service discovery to
 *      obtain the server channel number on the AG device, then registers using
 *      the DM_SM_REGISTER_OUTGOING_REQ primitive with 'protocol_id' =
 *      SEC_PROTOCOL_RFCOMM, 'channel' = remote server channel, 'bd_addr' =
 *      device address of the AG. When the outgoing connection is started,
 *      RFCOMM will request access from the Security Manager which will apply
 *      the security level registered for the outgoing connection. Incoming
 *      connections proceed as in (Eg 2).
 *
 *      Eg 4 - An application can specify the security requirements for access
 *      to RFCOMM by sending DM_SM_REGISTER_REQ with 'protocol_id' =
 *      SEC_PROTOCOL_L2CAP, 'channel' = 3, and 'outgoing_ok' = TRUE. Then L2CAP
 *      will request access from the Security Manager for all new RFCOMM
 *      connections.
 *
 *      Eg 5 - An application can specify the security requirements for access
 *      to LE connection oriented channels(L2CAP) by sending DM_SM_REGISTER_REQ 
 *      with 'protocol_id' = SEC_PROTOCOL_LE_L2CAP, 'channel' = 0xf, and 
 *      'outgoing_ok' = TRUE. Then L2CAP will request access from the Security 
 *      Manager for all new L2CAP LE connections for PSM = 0xf.
 *
 *      min_enc_key_size
 *          Minimum length of the encryption key size to access the service.
 *          Applications can configure the min_enc_key_size from range
 *          1 to 16 octets for the service using DM_SM_SERVICE_REGISTER_REQ_T
 *          or DM_SM_SERVICE_REGISTER_OUTGOING_REQ_T primitive.
 *          If the value is zero then it will be automatically set to default
 *          DEFAULT_ENC_KEY_SIZE_VAL.
 *
 *          For Services registered through DM_SM_REGISTER_REQ_T or
 *          DM_SM_REGISTER_OUTGOING_REQ_T primitive the minimum length of
 *          the encryption key size will be set to DEFAULT_ENC_KEY_SIZE_VAL.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;           /* Always DM_SM_REGISTER_REQ */
    phandle_t           phandle;        /* destination phandle */
    context_t           context;        /* Opaque context */
    DM_SM_SERVICE_T     service;        /* Protocol and channel */
    bool_t              outgoing_ok;    /* TRUE if applies to outgoing */
    dm_security_level_t security_level; /* Level of security to be applied */
} DM_SM_REGISTER_REQ_T;

typedef struct
{
    dm_prim_t           type;           /* Always DM_SM_SERVICE_REGISTER_REQ */
    phandle_t           phandle;        /* destination phandle */
    context_t           context;        /* Opaque context */
    DM_SM_SERVICE_T     service;        /* Protocol and channel */
    bool_t              outgoing_ok;    /* TRUE if applies to outgoing */
    dm_security_level_t security_level; /* Level of security to be applied */
    uint8_t             min_enc_key_size; /* Min enc key size to access the service */
} DM_SM_SERVICE_REGISTER_REQ_T;

typedef DM_SM_REGISTER_REQ_T DM_SM_REGISTER_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Registers the security requirements for outgoing connections to the
 *      specified protocol and channel on the specified remote device. This is
 *      typically used to control security when connecting to a remote RFCOMM
 *      server channel.
 *
 *      See the description of DM_SM_REGISTER_REQ (above) for more details.
 *
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;           /* Always DM_SM_REGISTER_OUTGOING_REQ */
    phandle_t           phandle;        /* destination phandle */
    context_t           context;        /* Opaque context */
    DM_CONNECTION_T     connection;     /* Protocol, channel and BD_ADDR */
    dm_security_level_t security_level; /* Level of security to be applied */
} DM_SM_REGISTER_OUTGOING_REQ_T;

typedef struct
{
    dm_prim_t           type;           /* Always DM_SM_SERVICE_REGISTER_OUTGOING_REQ */
    phandle_t           phandle;        /* destination phandle */
    context_t           context;        /* Opaque context */
    DM_CONNECTION_T     connection;     /* Protocol, channel and BD_ADDR */
    dm_security_level_t security_level; /* Level of security to be applied */
    uint8_t             min_enc_key_size; /* Min enc key size to access the service */
} DM_SM_SERVICE_REGISTER_OUTGOING_REQ_T;

typedef DM_SM_REGISTER_OUTGOING_REQ_T DM_SM_REGISTER_OUTGOING_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Unregisters the security requirements for a service previously
 *      registered with DM_SM_REGISTER_REQ. 'protocol_id' and 'channel' are the
 *      same as in the register request.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;           /* Always DM_SM_UNREGISTER_REQ */
    phandle_t           phandle;
    context_t           context;
    DM_SM_SERVICE_T     service;        /* Protocol and channel */
} DM_SM_UNREGISTER_REQ_T;

typedef DM_SM_UNREGISTER_REQ_T DM_SM_UNREGISTER_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Unregisters the security requirements for a service previously
 *      registered with DM_SM_REGISTER_OUTGOING_REQ. 'bd_addr', 'protocol_id'
 *      and 'remote_channel' are the same as in the register request.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;           /* Always DM_SM_UNREGISTER_OUTGOING_REQ */
    phandle_t           phandle;
    context_t           context;
    DM_CONNECTION_T     connection;     /* Protocol, channel and BD_ADDR */
} DM_SM_UNREGISTER_OUTGOING_REQ_T;

typedef DM_SM_UNREGISTER_OUTGOING_REQ_T DM_SM_UNREGISTER_OUTGOING_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Request from a protocol layer (e.g. L2CAP, RFCOMM, or a higher layer) to
 *      determine if the remote device 'bd_addr' is to be granted access to that
 *      protocol layer's channel.
 *      The Security Manager will search its service and device databases, may
 *      perform some security procedures, and may request authorisation from
 *      the application. The result is returned in a DM_SM_ACCESS_CFM_T
 *      primitive.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;               /* Always DM_SM_ACCESS_REQ */
    phandle_t               phandle;            /* phandle for the response */

    /* Protocol, channel, BD_ADDR and incoming/outgoing. */
    DM_CONNECTION_SETUP_T   conn_setup;

    /* An opaque value supplied by the requesting entity, and returned in the
     * access confirm primitive. It may be used to match a confirm to the
     * correct request.
     */
    uint32_t                context;
} DM_SM_ACCESS_REQ_T;


/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Response to an access request from a protocol layer. This is sent to
 *      the phandle that was sent in the DM_SM_ACCESS_REQ primitive.
 * 
 *      For LE services, incase of failure, error status would be conveyed from
 *      DM_GAP_LE_ERROR_BASE range.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;               /* Always DM_SM_ACCESS_CFM */
    phandle_t               phandle;            /* Destination phandle */

    /* The parameters from the access request */
    DM_CONNECTION_SETUP_T   conn_setup;

    /* Context value supplied in the request */
    uint32_t                context;

    /* Anything other than HCI_SUCCESS is a failure */
    hci_return_t            status;
} DM_SM_ACCESS_CFM_T;

typedef DM_SM_ACCESS_CFM_T DM_SM_ACCESS_IND_T;

typedef struct
{
    dm_prim_t               type;
    phandle_t               phandle;
    TYPED_BD_ADDR_T         addrt;
    context_t               context;
    bool_t                  verify;
    uint16_t                length;
    uint8_t                *data;
    uint8_t                 status;
} DM_SM_DATA_SIGN_REQ_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef DM_SM_DATA_SIGN_REQ_T DM_SM_DATA_SIGN_COMMON_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */
typedef DM_SM_DATA_SIGN_COMMON_T DM_SM_DATA_SIGN_CFM_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef struct
{
    dm_prim_t               type;
    phandle_t               phandle;
    bool_t                  local_csrk;
    TYPED_BD_ADDR_T         addrt;
    uint32_t                counter;
} DM_SM_CSRK_COUNTER_CHANGE_IND_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Initialise Security Manager. The result is returned in a
 *      DM_SM_INIT_CFM primitive.
 *
 *      It is recommended that this is used once as part of the device
 *      initialisation, but it can be used multiple times using the 'options'
 *      field to specify which parameters are being initialised.
 *
 *      It is recommended that the security mode is changed only when the
 *      system is not in the process of creating or accepting any new
 *      connections. A device conforming to Bluetooth 2.0 or earlier must
 *      never enter Security Mode 4. A device conforming to Bluetooth 2.1
 *      or later must enter Security Mode 4 before making itself connectable
 *      or discoverable and before initiating any connections. It is
 *      recommended that a device conforming to Bluetooth 2.1 or later
 *      should enter Security Mode 4 as part of its initialisation process.
 *
 *      Mode 0 is for use by applications which perform their own security
 *      procedures. The service database is unused in this mode, whereas the
 *      device database is used only for link keys. Unknown link keys result in
 *      a link key request being forwarded to the application. This is the
 *      default mode at startup.
 *
 *      In mode 1, the Security Manager automatically accepts all access
 *      requests without initiating authentication, encryption, or
 *      authorisation procedures. Any attempt by an application to perform
 *      authentication or encryption procedures will be rejected. The Security
 *      Manager will respond to peer-invoked security procedures as for mode 2.
 *
 *      In mode 2, access requests are subject to the security requirements
 *      registered in the service and device databases. The Security Manager
 *      will respond to link key requests using the device database - if a link
 *      key is unknown, the request is forwarded to the application. PIN code
 *      requests are forwarded to the application. The application may invoke
 *      security procedures in this mode.
 *
 *      In mode 3, the host controller is configured to perform authentication
 *      and possibly encryption at LMP link setup. The Security Manager still
 *      uses the service database to control authorisation and encryption.
 *      The encryption level for mode 3 is specified in 'mode3_enc'. If the host
 *      controller will not enter authentication mode, then the request fails
 *      (DM_SM_INIT_CFM has a negative response). If the host controller
 *      does enter authentication mode, then the request succeeds. Note that the
 *      requested encryption level may not be supported - in this case the
 *      request still succeeds and the actual encryption level is returned in
 *      DM_SM_INIT_CFM.
 *
 *      In mode 4, security is service-based, like in mode 2. Secure simple
 *      pairing is turned on in mode 4 and we now do authorisation before
 *      authentication. A device must be put into mode 4 to be V2.1 compliant
 *      Once in mode 4, you cannot change to any other mode.
 *
 *      Sets the default security level to be applied in security modes 2, 3
 *      and 4 in cases where a service has not been registered with the
 *      Security Manager. The "default" default security level is defined by
 *      SECL_DEFAULT, and using this primitive overrides SECL_DEFAULT.
 *
 *      write_auth_enable
 *          This controls when the security manager issues WRITE_AUTH_ENABLE
 *          to do mode3-style pairing with legacy devices.
 *          See DM_SM_BONDING_REQ for a description of this parameter.
 *
 *      config
 *          This is a bitfield for general config.
 *
 *          bit 0 - Reserved. Shall be set to zero.
 *          bit 1 - Reserved. Shall be set to zero.
 *          bit 2 - DM_SM_SEC_MODE_CONFIG_DEBUG_MODE
 *          This bit should only be set for debugging using traces.
 *          If set then the security manager will be put into debug mode.
 *          HCI_WRITE_SIMPLE_PAIRING_DEBUG_MODE will be issued to the
 *          controller and the security manager will start generating
 *          link keys with debug type. You can exit debug mode by
 *          resending this primitive with this bit unset.
 *
 *          bit 3 - DM_SM_SEC_MODE_CONFIG_LEGACY_AUTO_PAIR_MISSING_LINK_KEY
 *          If set then the security manager will automatically start
 *          pairing if authentication of a legacy device fails with
 *          'missing link key'.
 *
 *          bit 4 - DM_SM_SEC_MODE_CONFIG_NEVER_AUTO_ACCEPT
 *          Setting this bit will allow application to be looped in while
 *          pairing.
 *          If set then the device manager will always issue a
 *          DM_SM_USER_CONFIRMATION_REQUEST_IND primitive instead of
 *          auto-accepting, irrespective of the local IO capabilities or
 *          the authentication requirements of either device.
 *
 *          bit 5 - DM_SM_SEC_MODE_CONFIG_ALWAYS_TRY_MITM
 *          Setting this bit is not recommended and should not be necessary.
 *          If set then the local device will always request MITM protection
 *          during pairing. If it isn't possible to generate an authenticated
 *          link key and the local device would not otherwise have requested
 *          MITM protection then the local device will not abort pairing and
 *          will allow the generation of an unauthenticated link key.
 *
 *----------------------------------------------------------------------------*/

 /*
 * write_auth_enable (bitfield)
 */

/* Never pair during link setup. Use this if you know that the remote host
 * supports SSP and SM4 or if you plan to avoid timeouts some other way
 */
#define DM_SM_WAE_NEVER             0x0000

/* Pair during link setup if an ACL does not exist */
#define DM_SM_WAE_ACL_NONE          0x0001

/* Note: The values below are chosen so that they will mask out all
   ACL ownership locks that they effectively override. */

/* Pair during link setup, first tearing down any existing ownerless ACL
 * This implies DM_SM_WAE_ACL_NONE
 */
#define DM_SM_WAE_ACL_OWNER_NONE    0x000F

/* Pair during link setup, first tearing down any existing ownerless or
 * APP-owned ACL.
 * This implies DM_SM_WAE_ACL_NONE and DM_SM_WAE_ACL_OWNER_NONE
 */
#define DM_SM_WAE_ACL_OWNER_APP     0x00FF

/* Pair during link setup, first tearing down any existing ownerless or
 * L2CAP-owned ACL. This will of course close the l2cap connection(s).
 * This implies DM_SM_WAE_ACL_NONE and DM_SM_WAE_ACL_OWNER_NONE
 */
#define DM_SM_WAE_ACL_OWNER_L2CAP   0x0F0F

/* Pair during link setup, first tearing down any existing ownerless or
 * SYNC Manager-owned ACL. This will of course close any existing (e)SCO
 * connection(s). This implies DM_SM_WAE_ACL_NONE and
 * DM_SM_WAE_ACL_OWNER_NONE
 */
#define DM_SM_WAE_ACL_OWNER_SYNC    0xF00F

/* Pair during link setup, first tearing down any existing ACL */
#define DM_SM_WAE_ALWAYS            0xFFFF

/*
 * config (bitfield)
 */
#define DM_SM_SEC_MODE_CONFIG_NONE                              0x0000
#define DM_SM_SEC_MODE_CONFIG_RESERVED1                         0x0001
#define DM_SM_SEC_MODE_CONFIG_RESERVED2                         0x0002
#define DM_SM_SEC_MODE_CONFIG_DEBUG_MODE                        0x0004
#define DM_SM_SEC_MODE_CONFIG_LEGACY_AUTO_PAIR_MISSING_LINK_KEY 0x0008
#define DM_SM_SEC_MODE_CONFIG_NEVER_AUTO_ACCEPT                 0x0010
#define DM_SM_SEC_MODE_CONFIG_ALWAYS_TRY_MITM                   0x0020
#define DM_SM_SEC_MODE_CONFIG_SC_ONLY_MODE                      0x0040
/* The flag below disables Cross Transport Key Derivation on
 * both the transports during SC pairing.
 */
#define DM_SM_SEC_MODE_CONFIG_DISABLE_CTKD                      0x0080
/* The flag below allows application to selectively derive keys
 * for the other transport with a remote device if possible using 
 * cross transport key derivation(CTKD) feature. 
 * The application shall, in this case, be asked for a response
 * to go ahead with CTKD at the time of pairing.
 * This feature bit shall be ignored if
 * DM_SM_SEC_MODE_CONFIG_DISABLE_CTKD is already set.
 */
#define DM_SM_SEC_MODE_CONFIG_SELECTIVE_CTKD                    0x0100

/*
 * options
 *
 * Note that for implementation reasons, multiple bits are assigned to some
 * options. Use the definitions below to ensure that you set either all
 * required bits or none.
 */
#define DM_SM_INIT_SECURITY_MODE            ((1<<0) | (1<<1) | (1<<2) | (1<<8))
#define DM_SM_INIT_SECURITY_LEVEL_DEFAULT   (1<<3)
#define DM_SM_INIT_CONFIG                   ((1<<4) | (1<<5))
#define DM_SM_INIT_WRITE_AUTH_ENABLE        (1<<6)
#define DM_SM_INIT_MODE3_ENC                ((1<<7) | (1<<8))
#define DM_SM_INIT_SM_STATE                 (1<<9)
#define DM_SM_INIT_ENC_SIZE_CONF            (1<<10)
#define DM_SM_INIT_SECURE_CONNECTIONS       (1<<11)
#define DM_SM_INIT_ALL_BREDR (DM_SM_INIT_SECURITY_MODE \
                            | DM_SM_INIT_SECURITY_LEVEL_DEFAULT \
                            | DM_SM_INIT_CONFIG \
                            | DM_SM_INIT_WRITE_AUTH_ENABLE \
                            | DM_SM_INIT_MODE3_ENC)
#define DM_SM_INIT_ALL_SC_BREDR (DM_SM_INIT_SECURITY_MODE \
                               | DM_SM_INIT_SECURE_CONNECTIONS \
                               | DM_SM_INIT_SECURITY_LEVEL_DEFAULT \
                               | DM_SM_INIT_CONFIG \
                               | DM_SM_INIT_WRITE_AUTH_ENABLE \
                               | DM_SM_INIT_MODE3_ENC)
#define DM_SM_INIT_ALL_LE    (DM_SM_INIT_CONFIG \
                            | DM_SM_INIT_SM_STATE )
#define DM_SM_INIT_ALL_LE_SC  (DM_SM_INIT_ALL_LE \
                            | DM_SM_INIT_SECURE_CONNECTIONS )
#define DM_SM_INIT_ALL       (DM_SM_INIT_ALL_BREDR \
                            | DM_SM_INIT_ALL_LE \
                            | DM_SM_INIT_ENC_SIZE_CONF)
#define DM_SM_INIT_ALL_SC    (DM_SM_INIT_ALL_SC_BREDR \
                            | DM_SM_INIT_ALL_LE_SC \
                            | DM_SM_INIT_ENC_SIZE_CONF)

/*  Reset Root keys (er and ir) with these macros. 

    Root keys are used as a seed to generate local keys that are distributed
    to remote devices while bonding. Resetting root key will generate 
    new er,ir values and it will be sent in SM_INIT_CFM for application to store
    them in in a non-volatile area (e.g. PSKEY). 
    Resetting root keys will make all the existing bonding information invalid */

#define DM_SM_INIT_ALL_AND_RESET_ROOT_KEYS  \
                                (DM_SM_INIT_ALL & ~DM_SM_INIT_SM_STATE)
#define DM_SM_INIT_ALL_SC_AND_RESET_ROOT_KEYS \
                                (DM_SM_INIT_ALL_SC & ~DM_SM_INIT_SM_STATE)

#define MAX_ENC_KEY_SIZE_VAL      0x10
#define MIN_ENC_KEY_SIZE_VAL      0x07
/* Default encryption key size value to access BREDR services. See B-281257 */
#define DEFAULT_ENC_KEY_SIZE_VAL  0x07

typedef struct
{
    uint16_t er[8];
    uint16_t ir[8];
} DM_SM_KEY_STATE_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef struct
{
    dm_prim_t           type;               /* Always DM_SM_INIT_REQ */

    /* Bitfield of options.

       Just bitwise OR required options together.

       Note: write_auth_enable and mode3_enc are mutually exclusive.
       mode3_enc only applies to Security Mode 3. write_auth_enable
       applies to Security Modes 2 and 4. The Security Manager will
       process the security mode option first (if present) and then
       will try to set mode3_enc or write_auth_enable depending on
       what security mode it finds itself in and whether the relevant
       option has been switched on. It's safe to try to set both.
       The Security Manager will just ignore the one that doesn't
       apply.

       If sm_key_state(Root keys) are not available with application then
       it is required to get unique random numbers generated by Bluestack.
       To do so,"DM_SM_INIT_SM_STATE" bit shall not be set in options. It
       is likely that application will not have root keys for very first
       power cycle of product or when product undergoes factory reset. */

    uint16_t            options;

    /* Which security mode to use */
    dm_security_mode_t  security_mode;

    /* Default security level. */
    dm_security_level_t security_level_default;

    /* Configuration flags. */
    uint16_t            config;

    /* Specify when we issue HCI_WRITE_AUTH_ENABLE - See DM_SM_BONDING_REQ */
    uint16_t            write_auth_enable;

    /* Encryption level for mode 3. One of:
     *  HCI_ENC_MODE_OFF
     *  HCI_ENC_MODE_PT_TO_PT
     *  HCI_ENC_MODE_PT_TO_PT_AND_BCAST
     */
    uint8_t             mode3_enc;

    /* This records the state of the BLE Security Manager. It contains the
       master identity and encryption keys, together with the encryption
       key diversifier state.

       When an application boots for the first time, it should not attempt to
       set these and DM_SM_INIT_SM_STATE bit in options. The Security Manager will then 
       generate the keys and initiate the diversifier. It will return these
       values to the application in the DM_SM_INIT_CFM_T. The application must
       then store these values in a non-volatile area (e.g. PSKEY).

       During some pairing processes, the security manager may send new values
       of the diversifier - div - to the application. The application must
       update the diversifier in non-volatile memory.

       During subsequent boots, the application must return its stored values
       for the keys and diversifier to the Security Manager in DM_SM_INIT_REQ
       and set DM_SM_INIT_SM_STATE flag in options.

       Failure to do this will mean that any keys distributed from this
       device will be rendered invalid at the next reboot. */
    DM_SM_KEY_STATE_T   sm_key_state;
    uint16_t            sm_div_state;
    uint32_t            sm_sign_counter;

    /* Configurable encryption key size (max/min) values */
    uint8_t             max_enc_key_size_thres; /* Maximun enc key size threshold param */
    uint8_t             min_enc_key_size_thres; /* Minimum enc key size threshold param */
} DM_SM_INIT_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Confirmation of Security Manager INIT request.
 *
 *----------------------------------------------------------------------------*/
/* Bitfield to indicate success or failure.
   0 is success, otherwise set bits indicate any problems that were
   encountered. */
/* The security manager does not recognise the security mode. */
#define DM_SM_INIT_FAIL_UNSUPPORTED_SECURITY_MODE           ((uint16_t)0x0001)
/* HCI_WRITE_SIMPLE_PAIRING_MODE failed. Can't start Security Mode 4 */
#define DM_SM_INIT_FAIL_WRITE_SIMPLE_PAIRING_MODE           ((uint16_t)0x0002)
/* HCI_WRITE_SIMPLE_PAIRING_DEBUG_MODE failed. Can't debug Security Mode 4 */
#define DM_SM_INIT_FAIL_WRITE_SIMPLE_PAIRING_DEBUG_MODE     ((uint16_t)0x0004)
/* HCI_WRITE_AUTH_ENABLE failed. Can't enter/exit Security Mode 3 */
#define DM_SM_INIT_FAIL_WRITE_AUTHENTICATION_ENABLE         ((uint16_t)0x0008)
/* HCI_WRITE_ENC_MODE failed. Can't change Security Mode 3 encryption mode */
#define DM_SM_INIT_FAIL_WRITE_ENCRYPTION_MODE               ((uint16_t)0x0010)
/* HCI_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT failed. Can't enter Security Mode 4 encryption mode */
#define DM_SM_INIT_FAIL_WRITE_SC_HOST_SUPPORT               ((uint16_t)0x0020)
typedef struct
{
    dm_prim_t           type;               /* Always DM_SM_INIT_CFM */
    phandle_t           phandle;            /* Destination phandle */

    /* Current security mode. */
    dm_security_mode_t  security_mode;

    /* Current default security level. */
    dm_security_level_t security_level_default;

    /* Current configuration flags. */
    uint16_t            config;

    /* Current specification for use of HCI_WRITE_AUTH_ENABLE. */
    uint16_t            write_auth_enable;

    /* Current encryption level for mode 3. */
    uint8_t             mode3_enc;

    uint16_t            status;

    DM_SM_KEY_STATE_T   sm_key_state;
    uint16_t            sm_div_state;
    uint32_t            sm_sign_counter;
} DM_SM_INIT_CFM_T;

/*---------------------------------------------------------------------------*
 * PURPOSE
 *      A request from the Security Manager for a link key required for
 *      authentication with the specified remote device. The application must
 *      respond with a DM_SM_LINK_KEY_REQUEST_RSP primitive containing
 *      the link and type, or with no link key and 'key_type' set to
 *      DM_SM_KEY_TYPE_NONE to reject the request. 'authenticated' will be
 *      set to TRUE if an authenticated link key is required.
 *
 *      The Security Manager will only issue a link key request if it does
 *      not already have a suitable link key for that device in the device
 *      database.
 *
 *      If an ACL exists then rhsf will provide the first 15 bits of the
 *      remote host's supported features. Currently only one bit is defined
 *      (bit 0), which is 1 if the remote host supports SSP and 0 if it
 *      doesn't (legacy pre-2.1 host). If no ACL exists then we return 0xFFFF.
 *
 *      If this parameter is set to 0 and initiated_outgoing is TRUE then sending
 *      a negative response will tell the security manager to initiate legacy
 *      pairing on an existing ACL. This can potentially lead to timeouts on
 *      some devices. To try to avoid timing out, you may want to prefetch
 *      the PIN from the user, set up an SDP 'ping' to keep the ACL alive, or
 *      whatever you did to avoid these problems in SM2.
 *
 *---------------------------------------------------------------------------*/

/* rhsf parameter */
#define DM_SM_RHSF_NO_ACL   0xFFFF
#define DM_SM_RHSF_NONE     0x0000
#define DM_SM_RHSF_SSP      0x0001

typedef struct
{
    dm_prim_t           type;           /* DM_SM_LINK_KEY_REQUEST_IND */
    phandle_t           phandle;        /* Destination phandle */
    BD_ADDR_T           bd_addr;        /* address of remote device */

    /* Class of device for peer, valid for incoming connections only else 0 */
    uint24_t            dev_class;

    bool_t              authenticated;  /* TRUE if we need authenticated key */
    /* TRUE if this is security for an outgoing connection that we've initiated */
    bool_t              initiated_outgoing;
    uint16_t            rhsf;           /* Remote host's supported features */
} DM_SM_LINK_KEY_REQUEST_IND_T;

/*---------------------------------------------------------------------------*
 * PURPOSE
 *      A response to DM_SM_LINK_KEY_REQUEST_RES
 *
 *      To respond with a suitable link key, set 'key_type' according to
 *      'HCI Link Key Notification Event Key Type', in hci.h, and then put
 *      the link key at the end of the primitive as normal.
 *
 *      To reject the request, set 'key_type' to DM_SM_KEY_TYPE_NONE and
 *      add nothing to the end of the primitive.
 *
 *---------------------------------------------------------------------------*/

/* key_type */
#define DM_SM_LINK_KEY_NONE                 ((uint8_t) 0xFE)
#define DM_SM_LINK_KEY_LEGACY               HCI_COMBINATION_KEY
#define DM_SM_LINK_KEY_DEBUG                HCI_DEBUG_COMBINATION_KEY
#define DM_SM_LINK_KEY_UNAUTHENTICATED_P192 HCI_UNAUTHENTICATED_COMBINATION_KEY_P192
#define DM_SM_LINK_KEY_AUTHENTICATED_P192   HCI_AUTHENTICATED_COMBINATION_KEY_P192
#define DM_SM_LINK_KEY_CHANGED              HCI_CHANGED_COMBINATION_KEY
#define DM_SM_LINK_KEY_UNAUTHENTICATED_P256 HCI_UNAUTHENTICATED_COMBINATION_KEY_P256
#define DM_SM_LINK_KEY_AUTHENTICATED_P256   HCI_AUTHENTICATED_COMBINATION_KEY_P256

typedef struct
{
    dm_prim_t           type;           /* DM_SM_LINK_KEY_REQUEST_RSP */

    BD_ADDR_T           bd_addr;        /* Remote device address */

    /* See HCI Link Key Notification Event Key Type in hci.h */
    uint8_t            key_type;

    uint8_t             *key;
} DM_SM_LINK_KEY_REQUEST_RSP_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      A request from the Security Manager for a PIN code required for
 *      pairing with the specified remote device. The application must respond
 *      with a DM_SM_PIN_REQUEST_RSP primitive containing the PIN code, or
 *      with 'pin_length' set to 0 to reject the request.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_SM_PIN_REQUEST_IND */
    phandle_t           phandle;            /* Destination phandle */

    /* The address of the remote device for which a PIN is required */
    TYPED_BD_ADDR_T     addrt;
    /* Class of device for peer, valid for incoming connections only else 0 */
    uint24_t            dev_class;

    bool_t              initiator;          /* TRUE if we initiated pairing */
} DM_SM_PIN_REQUEST_IND_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      A response to the Security Manager containing the PIN for remote device
 *      'bd_addr'. If no PIN is known, then set 'pin_length' to zero to reject
 *      the request.
 *
 *      If pairing succeeds as a result of the PIN, then the Security Manager
 *      will issue a DM_SM_LINK_KEY_IND primitive, containing the new link key.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_SM_PIN_REQUEST_RSP */

    /* The address of the remote device for which a PIN was requested */
    TYPED_BD_ADDR_T     addrt;

    /* The PIN code - set 'pin_length' to zero to reject */
    uint8_t             pin_length;
    uint8_t             pin[HCI_MAX_PIN_LENGTH];
} DM_SM_PIN_REQUEST_RSP_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      A notification from the Security Manager that a new link key is now
 *      in force for the remote device 'bd_addr'. This can be as a result of
 *      pairing, or as a result of one of the devices requesting a change of
 *      link key with the Change_Connection_Link_Key HCI command.
 *
 *      The Security Manager keeps a copy of the new link key, and passes it up
 *      to the application for non-volatile storage.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_SM_LINK_KEY_IND */
    phandle_t           phandle;            /* Destination phandle */

    /* The address of the remote device with which pairing completed */
    BD_ADDR_T           bd_addr;

    /* The link key type and value. The type can be:
    *   HCI_COMBINATION_KEY
    *   Support for local as well as remote UNIT_KEY is 
    *   deprecated as of BT 5.1
    */
    uint8_t             key_type;
    uint8_t             key[SIZE_LINK_KEY];
} DM_SM_LINK_KEY_IND_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      A request for authorisation from the Security Manager to the
 *      application. This upstream primitive is also used for LE services 
 *      registered over L2CAP. This is only performed when an untrusted or 
 *      unknown device is attempting to access a service that requires 
 *      authorisation when in security mode 2 on BR/EDR transport and 
 *      for all security modes on LE transport.
 *
 *      The application must make a decision and then respond with a
 *      DM_SM_AUTHORISE_RSP primitive containing the result. Devices can be
 *      marked as trusted using the DM_SM_ADD_DEVICE_REQ primitive.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;       /* Always DM_SM_AUTHORISE_IND */
    phandle_t               phandle;    /* Destination phandle */
    DM_CONNECTION_SETUP_T   cs;         /* Protocol, channel, bd_addr and direction */
} DM_SM_AUTHORISE_IND_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Authorisation response from the application to the Security Manager.
 *
 *----------------------------------------------------------------------------*/
#define DM_SM_AUTHORISE_ACCEPT_BIT          0   /* Set to authorise connection */
#define DM_SM_AUTHORISE_TWICE_BIT           1   /* Set to apply to next connection as well (within life of ACL) */
#define DM_SM_AUTHORISE_LIFE_OF_ACL_BIT     2   /* Set to apply to all connections for life of ACL */

#define DM_SM_AUTHORISE_REJECT_ONCE         0x0000
#define DM_SM_AUTHORISE_ACCEPT_ONCE         (1 << DM_SM_AUTHORISE_ACCEPT_BIT)
#define DM_SM_AUTHORISE_REJECT_TWICE        (1 << DM_SM_AUTHORISE_TWICE_BIT)
#define DM_SM_AUTHORISE_ACCEPT_TWICE        \
    ((1 << DM_SM_AUTHORISE_ACCEPT_BIT) | (1 << DM_SM_AUTHORISE_TWICE_BIT))
#define DM_SM_AUTHORISE_REJECT_LIFE_OF_ACL  \
    (1 << DM_SM_AUTHORISE_LIFE_OF_ACL_BIT)
#define DM_SM_AUTHORISE_ACCEPT_LIFE_OF_ACL  \
    ((1 << DM_SM_AUTHORISE_ACCEPT_BIT) | (1 << DM_SM_AUTHORISE_LIFE_OF_ACL_BIT))

typedef struct
{
    dm_prim_t               type;       /* Always DM_SM_AUTHORISE_RSP */
    DM_CONNECTION_SETUP_T   cs;         /* Protocol, channel, bd_addr and direction */
    uint16_t                authorisation;  /* Nature of authorisation */
} DM_SM_AUTHORISE_RSP_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Applications may request authentication of a link at any time, using
 *      the DM_SM_AUTHENTICATE_REQ primitive. If the link has already been
 *      authenticated, the Security Manager responds immediately, otherwise it
 *      performs the HCI authentication procedure, which may involve pairing.
 *
 *      This request will be rejected in security mode 1.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_SM_AUTHENTICATE_REQ */

    /* Address of device to authenticate */
    BD_ADDR_T           bd_addr;
} DM_SM_AUTHENTICATE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Result of an authentication request.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_SM_AUTHENTICATE_CFM */
    phandle_t           phandle;            /* Destination phandle */

    /* Address of device being authenticated */
    BD_ADDR_T           bd_addr;

    /* TRUE if successful */
    bool_t              success;
} DM_SM_AUTHENTICATE_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Applications may request encryption activation or de-activation of a
 *      link at any time, using the DM_SM_ENCRYPT_REQ primitive. If the link
 *      encryption is already in the requested state, the Security Manager
 *      responds immediately, otherwise it performs the relevant HCI procedure.
 *      The link must have been authenticated before encryption is allowed.
 *      This API is to be used only for BREDR transport.
 *
 *      This request will be rejected in security mode 1.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_SM_ENCRYPT_REQ */

    /* Link to encrypt */
    BD_ADDR_T           bd_addr;

    /* TRUE to activate encryption, FALSE to stop encryption */
    bool_t              encrypt;
} DM_SM_ENCRYPT_REQ_T;


/*
 * encrypt_type parameter is part of following events
 * - DM_SM_ENCRYPTION_CHANGE_IND_T              meant for both transports
 * - DM_SM_ENCRYPTION_CHANGE_KEY_SIZE_IND_T     meant for both transports
 * - DM_SM_ENCRYPT_CFM_T                        meant for BREDR transport only
 */
#define DM_SM_ENCR_NONE                 0x0000
#define DM_SM_ENCR_ON_LE_AES_CCM        0x0001
#define DM_SM_ENCR_ON_BREDR_EO          0x0001
#define DM_SM_ENCR_ON_BREDR_AES_CCM     0x0002

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Result of a locally-initiated encryption request (DM_SM_ENCRYPT_REQ).
 *      This event is only generated for a BREDR transport.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_SM_ENCRYPT_CFM */
    phandle_t           phandle;            /* Destination phandle */

    /* Link being encrypted */
    BD_ADDR_T           bd_addr;

    /* TRUE if the command was successful, FALSE if it failed. The actual
     * encryption state of the link is in 'encrypted'.
     */
    bool_t              success;

    /* TRUE if encrypted, FALSE if not encrypted */
    bool_t              encrypted;
    uint16_t            encrypt_type;
} DM_SM_ENCRYPT_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Notification of a possible change in the encryption status of a link
 *      due to a peer-initiated encryption procedure.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;        /* Always DM_SM_ENCRYPTION_CHANGE_IND */
    phandle_t               phandle;     /* Destination phandle */

    /* Link being encrypted */
    TP_BD_ADDR_T            tp_addrt;

    /* TRUE if encrypted, FALSE if not encrypted */
    bool_t                  encrypted;
    uint16_t                encrypt_type;
} DM_SM_ENCRYPTION_CHANGE_IND_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Notification of an encryption change and key size, sent on 
 *      encryption change. 
 *      Note: The primitive DM_SM_ENCRYPTION_CHANGE_IND will be deprecated 
 *      in the future, DM_SM_ENCRYPTION_CHANGE_KEY_SIZE_IND is superset of 
 *      DM_SM_ENCRYPTION_CHANGE_IND, for now both of these indications 
 *      will be sent.
 *
 *----------------------------------------------------------------------------*/
#define DM_SM_ENCRYPTION_KEY_SIZE_NOT_FOUND         0xFF

typedef struct
{
    dm_prim_t       type;           /* Always DM_SM_ENCRYPTION_CHANGE_KEY_SIZE_IND */
    phandle_t       phandle;        /* Destination phandle */ 
    TP_BD_ADDR_T    tp_addrt;       /* Link being encrypted */ 
    bool_t          encrypted;      /* TRUE if encrypted, FALSE if not encrypted */
    uint16_t        encrypt_type;   /* Type of encryption */
    uint8_t         enc_key_size;   /* Encryption key size */
} DM_SM_ENCRYPTION_CHANGE_KEY_SIZE_IND_T;

typedef HCI_REFRESH_ENCRYPTION_KEY_T DM_HCI_REFRESH_ENCRYPTION_KEY_REQ_T;
typedef DM_HCI_TYPED_BD_ADDR_PT_COMMAND_CFM_T DM_HCI_REFRESH_ENCRYPTION_KEY_IND_T;

#define DM_HCI_REFRESH_ENCRYPTION_KEY_REQ  ((dm_prim_t)(ENUM_DM_HCI_REFRESH_ENCRYPTION_KEY_REQ))
#define DM_HCI_REFRESH_ENCRYPTION_KEY_IND  ((dm_prim_t)(ENUM_DM_HCI_REFRESH_ENCRYPTION_KEY_IND))

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *      Common RES and IND primitive for Secure Simple Pairing and SMP pairing
 *
 *---------------------------------------------------------------------------*/
/* flags field */
#define DM_SM_FLAGS_NONE                     0x0000
#define DM_SM_FLAGS_INITIATOR                0x0001 /* Pairing initiated locally */
#define DM_SM_FLAGS_SECURITY_MANAGER         0x0002 /* Security Manager used instead of LMP */
#define DM_SM_FLAGS_RESPONSE_REQUIRED        0x0004 /* Response required from application */
#define DM_SM_FLAGS_SMP_OVER_BREDR           0x0008 /* Indicates that events are part of SMP over BR/EDR
                                                     * irrespective of the transport type */
#define DM_SM_FLAGS_OVERWRITE_BREDR_LINK_KEY 0x0010 /* Overwrite BR/EDR link key */

typedef struct
{
    dm_prim_t               type;
    phandle_t               phandle;    /* Destination phandle */
    TP_BD_ADDR_T            tp_addrt;

    /* Class of device for peer, valid for incoming connections only else 0 */
    uint24_t                dev_class;

    uint16_t                flags;
} DM_COMMON_IND_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef struct
{
    dm_prim_t               type;
    TP_BD_ADDR_T            tp_addrt;
} DM_COMMON_RSP_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

/*---------------------------------------------------------------------------*
 *  DM_SM_IO_CAPABILITY_RESPONSE_IND
 *
 *      Reports parameters given by the other device.
 *      It is purely informative and you should not respond to it.
 *--------------------------------------------------------------------------*/
/* key_distribution field */
#define DM_SM_KEY_DIST_INITIATOR_ENC_CENTRAL    0x0001
#define DM_SM_KEY_DIST_INITIATOR_ID             0x0002
#define DM_SM_KEY_DIST_INITIATOR_SIGN           0x0004
#define DM_SM_KEY_DIST_INITIATOR_LINK_KEY       0x0008
#define DM_SM_KEY_DIST_RESPONDER_ENC_CENTRAL    0x0100
#define DM_SM_KEY_DIST_RESPONDER_ID             0x0200
#define DM_SM_KEY_DIST_RESPONDER_SIGN           0x0400
#define DM_SM_KEY_DIST_RESPONDER_LINK_KEY       0x0800

typedef struct
{
    dm_prim_t               type;       /* DM_SM_IO_CAPABILITY_RESPONSE_IND */
    phandle_t               phandle;    /* Destination phandle */
    TP_BD_ADDR_T            tp_addrt;
    uint8_t                 io_capability;
    uint8_t                 oob_data_present;
    uint8_t                 authentication_requirements;
    uint16_t                flags;  /* See flags field in DM_COMMON_IND_T */
    uint16_t                key_distribution;
} DM_SM_IO_CAPABILITY_RESPONSE_IND_T;

/*---------------------------------------------------------------------------*
 *  DM_SM_IO_CAPABILITY_REQUEST_IND
 *
 *  The Security Manager asks the application for IO capability information
 *
 *  authentication_requirements is present so that the application can
 *  request General Bonding during service-based security and so that
 *  the application can insist on MITM protection, overriding the
 *  security manager. Effectively, the application can upgrade the security
 *  requirements. Setting authentication_requirements for dedicated bonding
 *  will always be ignored by the security manager as this will only be done
 *  when you issue a DM_SM_BONDING_REQ or when you are the responder and the
 *  initiator has set its authentication_requirements for dedicated bonding.
 *
 *  For BLE security, the authentication_requirements field should be set
 *  using the DM_SM_SECURITY_ defines. See DM_SM_SECURITY_REQ.
 *
 *  Notes for BR/EDR:
 *      1. An Application cannot downgrade the security requirements. If the
 *      security manager believes that MITM protection is required then
 *      it will request an authenticated link key, irrespective of the
 *      authentication_requirements set in this primitive.
 *
 *      2. If you are doing dedicated bonding then the security manager will
 *      send appropriate authentication_requirements (i.e. it will send either
 *      HCI_MITM_NOT_REQUIRED_DEDICATED_BONDING or
 *      HCI_MITM_REQUIRED_DEDICATED_BONDING) to the remote device.
 *
 *      3. If you are doing service-based security then the security manager
 *      will send appropriate authentication_requirements (i.e. it will send
 *      HCI_MITM_NOT_REQUIRED_NO_BONDING, HCI_MITM_REQUIRED_NO_BONDING,
 *      HCI_MITM_NOT_REQUIRED_GENERAL_BONDING or
 *      HCI_MITM_REQUIRED_GENERAL_BONDING) to the remote device.
 *
 *      4. You should be careful about upgrading the security requirements
 *      to MITM protection required. It is probably only worth doing if
 *      you know that MITM protection is going to be required anyway. This
 *      might be the case when you are opening the RFCOMM MUX (which might
 *      not require MITM protection) in order to open an RFCOMM channel
 *      that does require MITM protection. You might be able to save some
 *      time by upgrading to MITM_REQUIRED when opening the MUX as this
 *      will avoid pairing twice.
 *
 *      5. Remember that if you insist on MITM protection and the
 *      io_capabilities of the two devices prevent the creation of
 *      an authenticated link key then pairing will fail.
 *
 *  If oob_data_present == 0 then both oob_hash_c and oob_rand_r shall be
 *  NULL and there shall be no associated data with the primitive.
 *
 *  For BR/EDR, if oob_data_present == 1 then oob_hash_c and oob_rand_r
 *  shall each point to SIZE_OOB_DATA words of OOB data. If you only have
 *  oob_hash_c then zero the oob_rand_r data.
 *
 *  For BLE, if oob_data_present == 2 then oob_hash_c shall point to
 *  SIZE_OOB_DATA words of OOB data. oob_rand_r shall be NULL.
 *
 *  For BLE SC, if oob_data_present == 1 then oob_hash_c and oob_rand_r
 *  shall each point to series of OOB hash and Rand based on the bits set
 *  from DM_SM_OOB_DATA_P256 and DM_SM_OOB_DATA_P192
 *  oob_hash_c = hash_xx|hash_yy
 *  oob_rand_r = rand_xx|rand_yy
 *
 *  Cross transport key derivation (Single pairing): This procedure can be done
 *  in two different ways,
 *
 *  1. LE SC key derivation and distribution over BR/EDR transport after
 *     successful BR/EDR SC pairing.
 *     Bluestack in a master role on BR/EDR transport by itself will decide 
 *     whether to initiate single pairing procedure or not after successful 
 *     BR/EDR SC pairing. LE SC key derivation and distribution will be
 *     automatically initiated by sending iocap request to the application 
 *     with DM_SM_FLAGS_SMP_OVER_BREDR flag set. Application may choose to 
 *     reject single pairing procedure by replying with 
 *     DM_SM_IO_CAPABILITY_REQUEST_NEG_RSP
 *     Once application replies to iocap request positively, Bluestack will try
 *     to derive and distribute LE keys on BR/EDR transport. If procedure is 
 *     successful then DM_SM_KEYS_IND event is sent to the application. 
 *     Upon completion of this procedure,status will be indicated to the 
 *     applications by sending DM_SM_SIMPLE_PAIRING_COMPLETE_IND event with 
 *     DM_SM_FLAGS_SMP_OVER_BREDR flag set.
 *
 *  2. Link key derivation from LTK during LESC pairing.
 *     Bluestack will own up setting or resetting of 'link key' bit during
 *     LESC pairing except in case of lost bond scenario as explained below.
 *     Later,if a link key is derived successfully then it will be
 *     sent to the application in a separate DM_SM_KEYS_IND event before LESC
 *     pairing procedure is concluded with DM_SM_SIMPLE_PAIRING_COMPLETE_IND .
 *
 *     Lost bond scenario:
 *     When peer has lost the keys for the local device and initiates the
 *     pairing procedure. And if the local device has the BR/EDR link key in the
 *     Bluestack SM database, DM_SM_FLAGS_OVERWRITE_BREDR_LINK_KEY flag bit
 *     will be set in DM_SM_IO_CAPABILITY_REQUEST_IND.
 *     Applications shall use key_distribution in DM_SM_IO_CAPABILITY_REQUEST_RSP
 *     to accept by setting the bit field (DM_SM_KEY_DIST_INITIATOR_LINK_KEY
 *     and DM_SM_KEY_DIST_RESPONDER_LINK_KEY) or reject (by not setting the
 *     bit field) to derive and overwrite the BR/EDR link key.
 *     Applications shall set these key_distribution bits only when Bluestack
 *     has asked for DM_SM_FLAGS_OVERWRITE_BREDR_LINK_KEY in
 *     DM_SM_IO_CAPABILITY_REQUEST_IND.
 *
 * NOTE:
 *  1. If Application wants Bluestack to disable Cross Transport Keys Derivation
 *     then it may set DM_SM_SEC_MODE_CONFIG_DISABLE_CTKD in DM_SM_INIT_REQ.
 *
 *  2. If an application wants Bluestack to selectively generate Cross Transport
 *     Keys then it needs to set DM_SM_SEC_MODE_CONFIG_SELECTIVE_CTKD in
 *     DM_SM_INIT_REQ. At the same time it needs to make sure that bit
 *     DM_SM_SEC_MODE_CONFIG_DISABLE_CTKD is NOT set .
 *     Refer DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_IND_T prim for more details
 *---------------------------------------------------------------------------*/
typedef DM_COMMON_IND_T DM_SM_IO_CAPABILITY_REQUEST_IND_T;


/*
 * OOB data can be P192 and/or P256 and so the following interface
 * needs to populate the oob_hash_c and oob_rand_r carefully
 * Hash to be populated in the following order if both the bits (for 192 and
 * 256)are set:
 * MSB-hash256|hash192-LSB...
 * MSB-rand256|rand192-LSB...
 * In case only one of them is being conveyed (P256) then we can just send
 * MSB-hash256-LSB...
 * MSB-rand256-LSB...
 */

/*
 * oob_data_present is a bit field and shall be used as below
 */

/* Possible values for oob_data_present */
#define DM_SM_OOB_DATA_NONE 0x00  /* No OOB data */

/*
 * For P192 on LE transport, only oob_hash_c shall be supplied
 * For P192 on BREDR transport, both oob_hash_c and oob_rand_r shall be supplied
 * For P256 on either transport, both oob_hash_c and oob_rand_r shall be supplied
 */
#define DM_SM_OOB_DATA_P192 0x01   /* P192 OOB Data Present */
#define DM_SM_OOB_DATA_P256 0x02   /* Both hash_c and Rand_r is present */

/*
 * Flag indicating that applications are flexible on their MITM requirements.
 * This would be sent as a part of io_capability and
 * can be set using the macros define below
 */
#define DM_SM_MITM_FLEXIBLE        0x80

/*
 * Macro for application to add or clear MITM flexibility.
 * The user of these macros shall provide pointer to the primitive
 */
#define DM_SM_SET_MITM_FLEXIBLE(pIOCapsReqRsp) \
    pIOCapsReqRsp->io_capability |= DM_SM_MITM_FLEXIBLE;
#define DM_SM_CLEAR_MITM_FLEXIBLE(pIOCapsReqRsp) \
    pIOCapsReqRsp->io_capability &= (~DM_SM_MITM_FLEXIBLE);
/*
 * When the device has been configured in SC ONLY mode, following parameters 
 * will have the default values irrespective of what Application provides
 * - MITM bit would be set in authentication_requirements
 * - SC   bit would be set in authentication_requirements
 * - MITM flexibility bit in io_capability would be reset
 */


/*---------------------------------------------------------------------------*
 *  DM_SM_IO_CAPABILITY_REQUEST_RSP
 *  This primitive is used to respond to initiation of pairing process both on 
 *  LE and BR/EDR transports.
 *  Apart from guideline provided in DM_SM_IO_CAPABILITY_REQUEST_IND for pairing,
 *  API usage is explained here. 
 *
 *  io_capability : Apart from IO capabilities from specification,this field's 
 *  MSB is utilized to indicate application flexibility on MITM requirement when 
 *  MITM flag is set in authentication_requirements field. At present, 
 *  MITM flexibility is supported only for LE.
 *  
 *  oob_data_present, oob_hash_c, oob_rand_r : Refer OOB related macros 
 *  explained above. 
 *
 *  authentication_requirements : bit mask used to request authentication 
 *  requirements of the user. Bit positions are used as explained in SMP 
 *  specification Ref : Core 4.2,Vol 3,Part H,Sec 3.5.1 and 3.5.2.
 *  Note : LE Secure Connection aware applications should always set SC bit in
 *  this API.
 *   
 *  key_distribution : bit mask used to specifies keys to be exchanged with 
 *  remote device during LE pairing. DM_SM_KEY_DIST_* set of macros are defined 
 *  to help user to select initiator and responder key distribution. 
 *  Note :
 *  A) LE Secure Connection aware applications shall always set both 
 *  initiator and responder Encryption key bit to 1.
 *  B) In case application uses resolvable private address, it is mandated for
 *  the application to set the initiator &  responder indentity bits to 1.
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;       /* DM_SM_IO_CAPABILITY_REQUEST_RSP */
    TP_BD_ADDR_T            tp_addrt;
    uint8_t                 io_capability; 
    uint8_t                 oob_data_present;
    uint8_t                 authentication_requirements;
    uint8_t                 *oob_hash_c;
    uint8_t                 *oob_rand_r;
    uint16_t                key_distribution;   /* SMP only */
} DM_SM_IO_CAPABILITY_REQUEST_RSP_T;


/*---------------------------------------------------------------------------*
 *  DM_SM_IO_CAPABILITY_REQUEST_NEG_RSP_T
 *  The error codes expected for DM_SM_IO_CAPABILITY_REQUEST_NEG_RSP_T
 *  shall be picked up from SM_ERROR_T like SM_ERROR_INVALID_PARAMETERS for
 *  LE based responses and hci_reason_t for BREDR based responses.
 *  Error codes would be classified based on the transport.
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;     /* DM_SM_IO_CAPABILITY_REQUEST_NEG_RSP */
    TP_BD_ADDR_T            tp_addrt;
    uint8_t                 reason;
} DM_SM_IO_CAPABILITY_REQUEST_NEG_RSP_T;

/*---------------------------------------------------------------------------*
 *  DM_SM_USER_CONFIRMATION_REQUEST_IND
 *
 *  This primitive is sent when the numeric comparison authentication model
 *  is being used for pairing and provides the application with the generated
 *  numeric value.
 *
 *  If io_cap_local indicates that the local device is capable of displaying
 *  the numeric value then the application shall display it until
 *  DM_SM_SIMPLE_PAIRING_COMPLETE_IND is received.
 *
 *  io_cap_remote is there for information only and indicates whether or
 *  not a correctly implemented remote device will be displaying the number.
 *
 *  flags is a bitfield defined above. See DM_COMMON_IND.
 *  If DM_SM_FLAGS_INITIATOR is set then this pairing has been initiated by
 *  the local device. If DM_SM_FLAGS_RESPONSE_REQUIRED is set then the
 *  application shall respond with either DM_SM_USER_CONFIRMATION_REQUEST_RSP
 *  or DM_SM_USER_CONFIRMATION_REQUEST_NEG_RSP. If
 *  DM_SM_FLAGS_RESPONSE_REQUIRED is not set then the application shall not
 *  respond (but shall still display the numeric value if io_cap_local
 *  indicates that it shall).
 *
 *  Note:
 *  If either device (local/remote) has IO capability as NoInputNoOutput then
 *  the numeric value is insignificant. So application shall ignore and also
 *  not display it.
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;               /* DM_SM_USER_CONFIRMATION_REQUEST_IND */
    phandle_t               phandle;            /* Destination phandle */
    TP_BD_ADDR_T            tp_addrt;

    /* Class of device for peer, valid for incoming connections only else 0 */
    uint24_t                dev_class;

    uint32_t                numeric_value;      /* Value to compare */
    uint8_t                 io_cap_local;       /* Effective IO capabilities of local device. */
    uint8_t                 io_cap_remote;      /* Effective IO capabilities of remote device. */
    uint16_t                flags;              /* See DM_COMMON_IND_T */
} DM_SM_USER_CONFIRMATION_REQUEST_IND_T;

typedef DM_COMMON_RSP_T DM_SM_USER_CONFIRMATION_REQUEST_RSP_T;
typedef DM_COMMON_RSP_T DM_SM_USER_CONFIRMATION_REQUEST_NEG_RSP_T;

/*---------------------------------------------------------------------------*
 *  DM_SM_USER_PASSKEY_REQUEST
 *
 *  The user must enter a six digit passkey.
 *  There is a separate primitive to reject the request
 *
 *---------------------------------------------------------------------------*/
typedef DM_COMMON_IND_T DM_SM_USER_PASSKEY_REQUEST_IND_T;

typedef struct
{
    dm_prim_t               type;       /* DM_SM_USER_PASSKEY_REQUEST_RSP */
    TP_BD_ADDR_T            tp_addrt;
    uint32_t                numeric_value;
} DM_SM_USER_PASSKEY_REQUEST_RSP_T;

typedef DM_COMMON_RSP_T DM_SM_USER_PASSKEY_REQUEST_NEG_RSP_T;

/*---------------------------------------------------------------------------*
 *  DM_SM_USER_PASSKEY_NOTIFICATION_IND
 *
 *  The passkey should be displayed on the local device so that it may be
 *  entered on the remote device.
 *
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;     /* DM_SM_USER_PASSKEY_NOTIFICATION_IND */
    phandle_t               phandle;  /* destination phandle */
    TP_BD_ADDR_T            tp_addrt;
    uint32_t                passkey;

    /* Class of device for peer, valid for incoming connections only */
    uint24_t                dev_class;
    uint16_t                flags;    /* See DM_COMMON_IND_T */
} DM_SM_USER_PASSKEY_NOTIFICATION_IND_T;

/*---------------------------------------------------------------------------*
 *  DM_SM_SEND_KEYPRESS_NOTIFICATION_REQ
 *
 *  Tell the remote device about keypresses during local passkey entry.
 *
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;    /* DM_SM_SEND_KEYPRESS_NOTIFICATION_REQ */
    TP_BD_ADDR_T            tp_addrt;
    uint8_t                 notification_type;
} DM_SM_SEND_KEYPRESS_NOTIFICATION_REQ_T;

/*---------------------------------------------------------------------------*
 *  DM_SM_KEYPRESS_NOTIFICATION_IND
 *
 *  Notification of keypresses during passkey entry on the remote device.
 *
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;      /* DM_SM_KEYPRESS_NOTIFICATION_IND */
    phandle_t               phandle;   /* destination phandle */
    TP_BD_ADDR_T            tp_addrt;
    uint8_t                 notification_type;
    uint16_t                flags;    /* See DM_COMMON_IND_T */
} DM_SM_KEYPRESS_NOTIFICATION_IND_T;

/*---------------------------------------------------------------------------*
 *  DM_SM_GENERATE_LOCAL_KEY_REQ
 *
 *  Request to generate local public-secret key pair. This can be called prior
 *  to pairing to reduce time taken to pair.
 *  For now this call would be effective only for LE transport.
 *  -------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;      /* DM_SM_GENERATE_LOCAL_KEY_REQ */
    PHYSICAL_TRANSPORT_T    tp_type;
} DM_SM_GENERATE_LOCAL_KEY_REQ_T;

/*---------------------------------------------------------------------------*
 *  DM_SM_GENERATE_LOCAL_KEY_CFM
 *
 *  Confirmation of public-secret key being generated. Once the keys are deleted
 *  then fresh oob data should be generated before using the OOB data
 *  for pairing.
 *  -------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;      /* DM_SM_GENERATE_LOCAL_KEY_CFM */
    phandle_t               phandle;   /* destination phandle */
    uint8_t                 status;    /* Generation success or failed */
    PHYSICAL_TRANSPORT_T    tp_type;
} DM_SM_GENERATE_LOCAL_KEY_CFM_T;

/*---------------------------------------------------------------------------*
 *  DM_SM_GENERATE_LOCAL_KEY_IND
 *
 *  Event indicating that keys are generated. This might happen automatically
 *  based on internal triggers like pairing.
 *
 *  -------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;      /* DM_SM_GENERATE_LOCAL_KEY_IND */
    phandle_t               phandle;   /* destination phandle */
    uint8_t                 status;    /* Generation success or failed */
    PHYSICAL_TRANSPORT_T    tp_type;
} DM_SM_GENERATE_LOCAL_KEY_IND_T;

/*---------------------------------------------------------------------------*
 *  DM_SM_LOCAL_KEY_DELETED_IND
 *
 *  Notification that the local public-secret key pair was deleted and next time
 *  around pairing would require a fresh pair of keys.
 *  This also indicates that unused OOB data if previously generated will
 *  no longer be valid.
 *
 *  -------------------------------------------------------------------------*/
 typedef struct
{
    dm_prim_t               type;      /* DM_SM_LOCAL_KEY_DELETED_IND */
    phandle_t               phandle;   /* destination phandle */
    PHYSICAL_TRANSPORT_T    tp_type;
} DM_SM_LOCAL_KEY_DELETED_IND_T;


/*---------------------------------------------------------------------------*
 *  DM_SM_READ_LOCAL_OOB_DATA_CFM
 *
 *  Notification of transport specific out of band data of the local device
 *  Out of band data includes local confirm value and local random value.
 *
 * OOB data can be P192 and/or P256
 * Hash will be populated in the following order if both the bits (for 192 and
 * 256)are set:
 * MSB-hash256|hash192-LSB...
 * MSB-rand256|rand192-LSB...
 * In case only one of them is being conveyed (P256),then format is as below
 * MSB-hash256-LSB...
 * MSB-rand256-LSB...
 * oob_data_present will be populated using the macros explained in
                 DM_SM_IO_CAPABILITY_REQUEST_RSP for the same purpose.
 *  -------------------------------------------------------------------------*/
 typedef struct
{
    dm_prim_t               type;       /* DM_SM_READ_LOCAL_OOB_DATA_CFM */
    phandle_t               phandle;    /* destination phandle */
    PHYSICAL_TRANSPORT_T    tp_type;
    uint8_t                 status;
    uint8_t                 oob_data_present;
    uint8_t                 *oob_hash_c;
    uint8_t                 *oob_rand_r;
} DM_SM_READ_LOCAL_OOB_DATA_CFM_T;

typedef enum
{
    DM_SM_APT_IGNORE,
    DM_SM_APT_BLUESTACK,
    DM_SM_APT_APPLICATION,
    /*
     * Marks end range. Do not remove DM_SM_APT_MAX.
     * New additions must be made above it.
     */
    DM_SM_APT_MAX
} DM_SM_APT_ROUTE_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

/* A couple of handy values for the APT itself - it's in units of 10ms,
 * and the spec default is 30s. */
#define DM_SM_APT_NO_CHANGE       0
#define DM_SM_APT_DEFAULT  (30 *100)

typedef struct
{
    dm_prim_t         type;
    phandle_t         phandle;
    TP_BD_ADDR_T      tp_addrt;
    uint16_t          authenticated_payload_timeout;
    DM_SM_APT_ROUTE_T route_event;
} DM_SM_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_REQ_T;

typedef struct
{
    dm_prim_t    type;
    phandle_t    phandle;
    TP_BD_ADDR_T tp_addrt;
    uint8_t      status;
} DM_SM_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_CFM_T;

/*---------------------------------------------------------------------------*
 *  New macros of Error Codes
 *
 *  Creating new errors in the HCI error code space for the SM protocol errors.
 *  Appearing in DM_SM_SECURITY_CFM and DM_SM_SIMPLE_PAIRING_COMPLETE_IND.
 *  (Note that DM_SM_SIMPLE_PAIRING_COMPLETE_IND reports real HCI error codes for BR/EDR.)
 *
 *  SM_ERROR_T - enum of error codes.
 *  DM_SM_CONVERT_SM_ERROR - Macro converting SM_ERROR to DM_SM making error codes
 *  for SM on interface level
 *  #defines's - Error codes above interface level for sm.
 *--------------------------------------------------------------------------*/

/*---------------------------------------------------------------------------*
 *  SM_ERROR_T
 *
 *  enum for the SM error codes
 *--------------------------------------------------------------------------*/
/*! SM Protocol error codes. */
typedef enum
{
    SM_ERROR_RESERVED,
    SM_ERROR_PASSKEY_ENTRY_FAILED,
    SM_ERROR_OOB_NOT_AVAILABLE,
    SM_ERROR_AUTHENTICATION_REQUIREMENTS,
    SM_ERROR_CONFIRM_VALUE_FAILED,
    SM_ERROR_PAIRING_NOT_SUPPORTED,
    SM_ERROR_ENCRYPTION_KEY_SIZE,
    SM_ERROR_COMMAND_NOT_SUPPORTED,
    SM_ERROR_UNSPECIFIED_REASON,
    SM_ERROR_REPEATED_ATTEMPTS,
    SM_ERROR_INVALID_PARAMETERS,
    SM_ERROR_DHKEY_CHECK_FAILED,
    SM_ERROR_NUMERIC_COMP_FAILURE,
    SM_ERROR_BR_EDR_PAIRING_IN_PROGRESS,
    SM_ERROR_CROSS_TRANS_KEY_GEN_NOT_ALLOWED,
    SM_ERROR_KEY_REJECTED,
    SM_ERROR_HOST_BUSY,
    /* Marks end range. Do not remove SM_ERROR_MAX. Addition to be made above it. */
    SM_ERROR_MAX
} SM_ERROR_T;

#define SM_ERROR_BASE                           0xC0

/*
 * Internal error codes used in Security Manager Protocol between Bluestack
 * and application.
 * Range reserved is 0xA0 to 0xBF (32 possible error codes) since error codes
 * for Security Manager Protol start from 0xC0 onwards.
 */
#define SM_INTERNAL_ERROR_BASE                  0xA0
#define SM_INT_ERR_ENCRYPTION_REFRESH_FAILED    (SM_INTERNAL_ERROR_BASE+1)
/* 
 * Once the application receives mentioned error code for pairing failed 
 * it would mean that next attempt on pairing on the current link shall lead
 * to the disconnecttion of the link.
 * Suggested way is that application wraps up any other ongoing activity on the
 * current link and then bring down this link before trying to pair with the 
 * same device.
 */
#define SM_INT_ERR_SMP_PDU_TIMEOUT              (SM_INTERNAL_ERROR_BASE+2)

/*---------------------------------------------------------------------------*
 *  DM_SM_CONVERT_SM_ERROR
 *
 *  Macro which maps SM_ERROR codes to DM_SM style error codes
 *  to avoid an overlap with HCI error codes for simple pairing complete ind.
 *--------------------------------------------------------------------------*/
/*lint -emacro(506, DM_SM_CONVERT_SM_ERROR) Evaluates to constant value boolean
                                            when sm_error is a constant */
#define DM_SM_CONVERT_SM_ERROR(sm_error) ((uint8_t)((sm_error) == 0 ? HCI_SUCCESS : (sm_error) + SM_ERROR_BASE))

/*---------------------------------------------------------------------------*
 *  #define's for mapped DM_SM error codes to SM_ERROR type.
 *--------------------------------------------------------------------------*/
#define DM_SM_ERROR_PASSKEY_ENTRY_FAILED        DM_SM_CONVERT_SM_ERROR(SM_ERROR_PASSKEY_ENTRY_FAILED)
#define DM_SM_ERROR_OOB_NOT_AVAILABLE           DM_SM_CONVERT_SM_ERROR(SM_ERROR_OOB_NOT_AVAILABLE)
#define DM_SM_ERROR_AUTHENTICATION_REQUIREMENTS DM_SM_CONVERT_SM_ERROR(SM_ERROR_AUTHENTICATION_REQUIREMENTS)
#define DM_SM_ERROR_CONFIRM_VALUE_FAILED        DM_SM_CONVERT_SM_ERROR(SM_ERROR_CONFIRM_VALUE_FAILED)
#define DM_SM_ERROR_PAIRING_NOT_SUPPORTED       DM_SM_CONVERT_SM_ERROR(SM_ERROR_PAIRING_NOT_SUPPORTED)
#define DM_SM_ERROR_ENCRYPTION_KEY_SIZE         DM_SM_CONVERT_SM_ERROR(SM_ERROR_ENCRYPTION_KEY_SIZE)
#define DM_SM_ERROR_COMMAND_NOT_SUPPORTED       DM_SM_CONVERT_SM_ERROR(SM_ERROR_COMMAND_NOT_SUPPORTED)
#define DM_SM_ERROR_UNSPECIFIED_REASON          DM_SM_CONVERT_SM_ERROR(SM_ERROR_UNSPECIFIED_REASON)
#define DM_SM_ERROR_REPEATED_ATTEMPTS           DM_SM_CONVERT_SM_ERROR(SM_ERROR_REPEATED_ATTEMPTS)
#define DM_SM_ERROR_INVALID_PARAMETERS          DM_SM_CONVERT_SM_ERROR(SM_ERROR_INVALID_PARAMETERS)
#define DM_SM_ERROR_HOST_BUSY                   DM_SM_CONVERT_SM_ERROR(SM_ERROR_HOST_BUSY)


/*---------------------------------------------------------------------------*
 *  DM_SM_SIMPLE_PAIRING_COMPLETE_IND
 *
 *  Indication that authentication has finished
 *
 *--------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;      /* DM_SM_SIMPLE_PAIRING_COMPLETE_IND */
    phandle_t               phandle;   /* destination phandle */
    TP_BD_ADDR_T            tp_addrt;
    uint8_t                 status;
    uint16_t                flags;     /* See DM_COMMON_IND_T */
} DM_SM_SIMPLE_PAIRING_COMPLETE_IND_T;

/*---------------------------------------------------------------------------*
 *  DM_SM_READ_LOCAL_OOB_DATA_REQ
 *
 *  The application may request transport specific local OOB data.
 *  This should then be transferred to the remote device via an OOB mechanism.
 *  Only the most recent set of OOB data retrieved may be used by a
 *  remote device for authentication.
 *  Application not supporting LESC shall not be calling into this API for LE transport.
 *
 *  Everytime DM_SM_LOCAL_KEY_DELETED_IND is received the OOB data generated 
 *  will be destroyed and the application shall use this API to generate fresh OOB data.
 *  Also everytime  an OOB authentication is carried the OOB data used 
 * would be destroyed.
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;      /* DM_SM_READ_LOCAL_OOB_DATA_REQ */
    PHYSICAL_TRANSPORT_T    tp_type;
} DM_SM_READ_LOCAL_OOB_DATA_REQ_T;

/*---------------------------------------------------------------------------*
 * DM_SM_BONDING_REQ/CFM
 *
 * The application requests bonding with a remote device. First we delete
 * any link key we have in the device database.
 *
 * If the remote device is in SM4 then we make sure an ACL exists before
 * authenticating it.
 *
 * If the remote device is legacy then the write_auth_enable parameter
 * determines in what circumstances we try to pair during link setup
 * (just like mode 3).
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;       /* DM_SM_BONDING_REQ */
    TYPED_BD_ADDR_T         addrt;      /* Remote device address */
    uint16_t                flags;      /* Reserved and shall be set to 0 */
} DM_SM_BONDING_REQ_T;

typedef struct
{
    dm_prim_t               type;       /* DM_SM_BONDING_CFM */
    phandle_t               phandle;    /* destination phandle */
    TYPED_BD_ADDR_T         addrt;      /* Remote device address */
    uint16_t                flags;      /* See DM_COMMON_IND_T */
    hci_error_t             status;
} DM_SM_BONDING_CFM_T;

/* The status field in DM_SM_BONDING_CFM_T returns a standard HCI error code,
   or one of the following two additional error codes. */
#define DM_SM_BONDING_CANCELLED   ((hci_error_t)0xFF)
/* DM_SM_BONDING_NO_PAIRING is generated when we cannot prevent the baseband
   from automatically authenticating an existing link key. This will only occur
   for legacy security modes, i.e., it will never happen in Security Mode 4.
   To avoid this error, close the ACL before bonding. */
#define DM_SM_BONDING_NO_PAIRING  ((hci_error_t)0xFE)

/*---------------------------------------------------------------------------*
 * DM_SM_BONDING_CANCEL_REQ
 *
 * The application requests that a previous DM_SM_BONDING_REQ be cancelled.
 *
 * This is not guaranteed to work but it stands a better chance of working
 * the earlier it is used.
 *
 * If the DM_SM_BONDING_REQ request is still queued then the security
 * manager will just remove it. If the ACL manager is currently trying to
 * connect an ACL for bonding, then the security manager will try to
 * cancel this. If the ACL is already up and the pairing process has started
 * then the security manager will issue negative replies to halt it as
 * soon as possible. If you set force = TRUE then, if all else fails,
 * the DM will cancel bonding by bringing down the ACL, even if there are
 * l2cap connections open.
 *
 * There is no DM_SM_BONDING_CANCEL_CFM, but if cancellation was successful
 * then the DM_SM_BONDING_CFM associated with the original bonding request
 * will return with status = DM_SM_BONDING_CANCELLED. If it was too late to
 * cancel bonding and pairing has already succeeded, DM_SM_BONDING_CFM will
 * return with status = DM_SM_BONDING_SUCCESS and it is then up to the
 * application to unbond the device.
 *
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;       /* DM_SM_BONDING_CANCEL_REQ */
    TYPED_BD_ADDR_T         addrt;      /* Remote device address */
    uint16_t                flags;      /* See DM_ACL_OPEN_REQ */
} DM_SM_BONDING_CANCEL_REQ_T;


/*
 * This bitfield is used to attach a purpose to DIV key.
 * When DIV key flow is done for generating CSRK (i.e. while using DM_SM_KEY_REQUEST_IND,
 * DM_SM_KEY_REQUEST_RSP and DM_SM_KEY_REQUEST_NEG_RSP primitives), this bit
 * must be present in key_type value.
 */
#define DM_SM_KEY_CSRK_BIT  0x0100

typedef enum
{
    DM_SM_KEY_NONE,
    DM_SM_KEY_ENC_BREDR,        /* BR/EDR link key */
    DM_SM_KEY_ENC_CENTRAL,      /* LTK + EDIV + RAND for central */
    DM_SM_KEY_DIV,              /* DIV for peripheral */
    DM_SM_KEY_SIGN,             /* CSRK */
    DM_SM_KEY_ID,               /* IRK */

    DM_SM_KEY_DIV_CSRK = (DM_SM_KEY_DIV|DM_SM_KEY_CSRK_BIT)
                                /*
                                 * This enum value would be strictly used only in case
                                 * of DM_SM_KEY_REQUEST_IND, DM_SM_KEY_REQUEST_RSP
                                 * and DM_SM_KEY_REQUEST_NEG_RSP primitives.
                                 * If DM_SM_KEY_DIV is used for above primitves, it
                                 * implicitly means LTK generation.
                                 */
} DM_SM_KEY_TYPE_T;

/* Combination/authenticated/unauthenticated link key for BR/EDR
   links */
typedef struct
{
    uint16_t link_key_type;
    uint16_t link_key[8];
} DM_SM_KEY_ENC_BREDR_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

/* This is the encryption information provided to us by the peer.
   It will be requested when we're in the central role and want
   to authenticate and encrypt the link. */
typedef struct
{
    uint16_t ediv;
    uint16_t rand[4];
    uint16_t ltk[8];
} DM_SM_KEY_ENC_CENTRAL_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

/* This is the identity information provided to us by the peer.
   The IRK can be used to identify devices using a resolvable
   private address. The identity address is the public or static
   address of the peer. */
typedef struct
{
    uint16_t irk[8];
} DM_SM_KEY_ID_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

/* This is the peer's signing key. We can use this to sign certain
   attribute protocol PDUs when sending them over an unencrypted link. */
typedef struct
{
    uint16_t csrk[8];
    uint32_t counter;
} DM_SM_KEY_SIGN_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef union
{
    DM_SM_KEY_ENC_BREDR_T enc_bredr;
    DM_SM_KEY_ENC_CENTRAL_T enc_central;
    uint16_t div;
    DM_SM_KEY_ID_T id;
    DM_SM_KEY_SIGN_T sign;
} DM_SM_RFCLI_UKEY_T;

/* Union of pointers to key structures, except for DM_SM_KEY_ENC_PERIPHERAL_T
   which is not a pointer. */
typedef union
{
    DM_SM_KEY_ENC_BREDR_T *enc_bredr;
    DM_SM_KEY_ENC_CENTRAL_T *enc_central;
    /* Allows peripheral to reconstruct LTK and CSRK given to central.
     * MS 2 bits of div indicates if div value is applicable for LTK  or CSRK or
     * both. This is a read only information should not be changed by
     * the application */
    uint16_t div;
    DM_SM_KEY_ID_T *id;
    DM_SM_KEY_SIGN_T *sign;
    void *none;
} DM_SM_UKEY_T;

#define DM_SM_MAX_NUM_KEYS 5
#define DM_SM_NUM_KEY_BITS 3
#define DM_SM_KEY_MASK 0x0007
#define DM_SM_KEYS_EXISTING         0x8000
#define DM_SM_KEYS_UPDATE_EXISTING  DM_SM_KEYS_EXISTING
#define DM_SM_KEYS_REPLACE_EXISTING 0x0000
#define DM_SM_DIV_LTK 0x4000
#define DM_SM_DIV_CSRK 0x8000
#define DM_SM_DIV_TYPE_MASK (DM_SM_DIV_LTK|DM_SM_DIV_CSRK)

/*
 * While using this macro, keys - one, two, three, four and five should
   have values from enum DM_SM_KEY_TYPE_T.
   Field update_or_replace should be either DM_SM_KEYS_UPDATE_EXISTING or
   DM_SM_KEYS_REPLACE_EXISTING.
 */
#define DM_SM_KEYS_PRESENT(one, two, three, four, five, update_or_replace) \
   ((((one) & DM_SM_KEY_MASK) << (DM_SM_NUM_KEY_BITS * 0)) | \
    (((two) & DM_SM_KEY_MASK) << (DM_SM_NUM_KEY_BITS * 1)) | \
    (((three) & DM_SM_KEY_MASK) << (DM_SM_NUM_KEY_BITS * 2)) | \
    (((four) & DM_SM_KEY_MASK) << (DM_SM_NUM_KEY_BITS * 3)) | \
    (((five) & DM_SM_KEY_MASK) << (DM_SM_NUM_KEY_BITS * 4)) | \
    (update_or_replace))

/* This structure can hold pairing information for both
   BR/EDR and LE physical transport.
*/
typedef struct
{
    /* The link security level met for exchanging these keys.
       8 LSBs represent auth_req in pairing request and pairing
       response PDU of SMP. However, bonding information bit from
       these LE SMP PDUs is meaningless when reflect in this parameter.
       8 MSBs of this parameter are reserved for future purpose.
       Please note that link security level for BR/EDR key (link key)
       is present in link key type (Refer to DM_SM_KEY_ENC_BREDR_T).
       Therefore, this parameter is meaningful only when LE related keys
       are present.
     */
    uint16_t security_requirements;

    /* The number of significant octets in the LTK */
    uint16_t encryption_key_size;

    /* Set the pointers to point to the appropriate keys and use values
       defined in the DM_SM_KEY_TYPE_T enum with the macro. The final
       argument to the macro is either DM_SM_KEYS_UPDATE_EXISTING, which
       will cause just the addition or replacement of any keys specified,
       or DM_SM_KEYS_REPLACE_EXISTING, which will delete all existing keys
       before adding the new keys specified. */
    uint16_t present;

    DM_SM_UKEY_T u[DM_SM_MAX_NUM_KEYS]; /* Array of pointers to keys */
} DM_SM_KEYS_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */


/* This API provides keys (pairing) information exchanged during pairing process
   with the device with typed BD ADDR - addrt.
   Note that this confirmation primitive carries information
   for pairing over both the transport, so if single pairing feature in LESC
   is designed to use this primitive for sending pairing information of both
   BR/EDR and LE transports in one go, the primitive does not require any
   change).
*/
typedef struct
{
    dm_prim_t type;             /* DM_SM_KEYS_IND */
    phandle_t phandle;          /* destination phandle */
    TYPED_BD_ADDR_T addrt;      /* Peer's address used during pairing */
    DM_SM_KEYS_T keys;          /* Security keys and requirements */
    TYPED_BD_ADDR_T id_addrt;   /* Peer's static or public address
                                   (zeroed if not present) */
} DM_SM_KEYS_IND_T;

/* Security requirements bitfield definitions

   DM_SM_SECURITY_BONDING - In Bluetooth Low Energy, devices bond by
   exchaning keys after the link has been encrypted. If the devices are
   not bonding then no key distribution should take place. Note that
   key distribution is determined by the key_distribution field in the
   DM_SM_IO_CAPABILITY_REQUEST_RSP primitive. (That field should be set
   to zero by any device that does not want to bond.)

   DM_SM_SECURITY_REFRESH_ENCRYPTION - This bit is used to enforce refresh of
   encryption on an already encrypted link.
   Note: Refresh encryption bit should be set only when LTK is available
   with the local device.

   DM_SM_SECURITY_ENCRYPTION - This bit specifies a requirement for an
   encrypted link. If there is no Out of Band data available then the
   security manager will default to using the Just Works pairing method
   and will produce an unauthenticated key with no MITM protection.
   Note: As per the table (below), this bit is in-significant and hence
         don't-care.

   DM_SM_SECURITY_MITM_PROTECTION - This bit specifies a requirement for
   MITM protection. If there is no Out of Band data available then the
   security manager will try to use passkey pairing. If the IO capabilities
   of the two devices do not allow this then the pairing will fail.

   DM_SM_SECURITY_QUERY_ONLY - This bit determines the security manager's
   behaviour upon finding that the current state of the link does not
   provide the security requested. If this bit is set then the secruity
   manager will simply report back failure. If it is not set then the
   security manager will initiate pairing to increase the security level.
   This bit is intended to be set only by ATT, which will need to query
   the current security level. The application will want to increase the
   security level to match its request and so should not set this bit.

    If requested security requirements are lesser or equal to
    the link's current security level
    Then
        Following table defines the action taken when authentication
        requirements corresponds to all possible combinations of
        - DM_SM_SECURITY_ENCRYPTION &
        - DM_SM_SECURITY_REFRESH_ENCRYPTION
        and the link's current status.
    Else
        Trigger pairing process.

    |------------------------------------------------------------------|
    | Encrypt   |   Encrypt Refresh   |    Link's current status       |
    | Request   |   Request           |--------------------------------|
    |           |                     |  Un-encrypted  |  Encrypted    |
    |           |                     |--------------------------------|
    |           |                     |            Action taken        |
    |-----------|---------------------|----------------|---------------|
    |      X    |      0              |    Encrypt     |   Do Nothing, |
    |           |                     |                |   Send Confm. |
    |           |                     |                |   SUCCESS     |
    |           |                     |                |               |
    |      X    |      1              |    Encrypt     |   Refresh     |
    |           |                     |                |               |
    |------------------------------------------------------------------|

    Note : If pairing was triggered as a result of DM_SM_SECURITY_REQ API call 
          then application shall set same security (auth) requirement set in 
          DM_SM_IO_CAPABILITY_REQUEST_RSP.
*/
#define DM_SM_SECURITY_BONDING          0x0001  /* Create a bond */
#define DM_SM_SECURITY_MITM_PROTECTION  0x0004  /* Protect against MITM */
#define DM_SM_SECURITY_SECURE_CONNECTIONS  0x0008  /* Enable secure connections */
#define DM_SM_SECURITY_REFRESH_ENCRYPTION 0x1000  /* Enforce encryption refresh
                                                     on an encrypted link */
#define DM_SM_SECURITY_ENCRYPTION       0x4000  /* As per the above table,
                                                   this bit is in-significant
                                                   and hence don't-care */
#define DM_SM_SECURITY_QUERY_ONLY       0x8000  /* Query current state */

/* 
 * Bluestack would set this in case H6 was used while deriving the 
 * cross transport keys in the DM_SM_KEYS_IND_T event only.
 * Application shall use this to confirm on its usage for various services.
 */
/* LE keys were derived using H6 */
#define DM_SM_SECURITY_LE_H6_SET           0x0100
/* BREDR key was derived using H6 */
#define DM_SM_SECURITY_BREDR_H6_SET        0x0200


#define DM_SM_LE_ENCRYPTION    0x01
#define DM_SM_LE_MITM          0x02
#define DM_SM_LE_SIGNING       0x04
#define DM_SM_LE_SC_ENCRYPTION 0x08


/* Security levels derived from bitfield definitions above */
#define DM_SM_SECURITY_NONE 0x0000
#define DM_SM_SECURITY_UNAUTHENTICATED_NO_BONDING \
    (DM_SM_SECURITY_ENCRYPTION)
#define DM_SM_SECURITY_UNAUTHENTICATED_BONDING \
    (DM_SM_SECURITY_UNAUTHENTICATED_NO_BONDING | DM_SM_SECURITY_BONDING)
#define DM_SM_SECURITY_AUTHENTICATED_NO_BONDING \
    (DM_SM_SECURITY_ENCRYPTION | DM_SM_SECURITY_MITM_PROTECTION)
#define DM_SM_SECURITY_AUTHENTICATED_BONDING \
    (DM_SM_SECURITY_AUTHENTICATED_NO_BONDING | DM_SM_SECURITY_BONDING)

/* Requesting Security levels for SC */
#define DM_SM_SECURITY_UNAUTHENTICATED_NO_BONDING_SC \
    (DM_SM_SECURITY_UNAUTHENTICATED_NO_BONDING | DM_SM_SECURITY_SECURE_CONNECTIONS)
#define DM_SM_SECURITY_UNAUTHENTICATED_BONDING_SC \
    (DM_SM_SECURITY_UNAUTHENTICATED_BONDING | DM_SM_SECURITY_SECURE_CONNECTIONS)
#define DM_SM_SECURITY_AUTHENTICATED_NO_BONDING_SC \
    (DM_SM_SECURITY_AUTHENTICATED_NO_BONDING | DM_SM_SECURITY_SECURE_CONNECTIONS)
#define DM_SM_SECURITY_AUTHENTICATED_BONDING_SC \
    (DM_SM_SECURITY_AUTHENTICATED_BONDING | DM_SM_SECURITY_SECURE_CONNECTIONS)

typedef struct
{
    dm_prim_t type;                 /* DM_SM_SECURITY_REQ */
    phandle_t phandle;              /* destination phandle */
    TYPED_BD_ADDR_T addrt;                  /* Peer's address */
    uint16_t connection_flags;      /* See l2ca_conflags_t in l2cap_prim.h */
    context_t context;              /* Opaque context returned in CFM */
    uint16_t security_requirements;
    hci_return_t status;            /* Indication of success or failure. Shall
                                       be set to 0 in DM_SM_SECURITY_REQ. */
} DM_SM_SECURITY_COMMON_T;  /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef DM_SM_SECURITY_COMMON_T DM_SM_SECURITY_REQ_T;
typedef DM_SM_SECURITY_COMMON_T DM_SM_SECURITY_CFM_T;
typedef DM_SM_SECURITY_COMMON_T DM_SM_SECURITY_IND_T;

typedef struct
{
    dm_prim_t type;                 /* DM_SM_KEY_REQUEST_IND */
    phandle_t phandle;              /* destination phandle */
    TYPED_BD_ADDR_T addrt;          /* Peer's address */
    uint16_t security_requirements; /* Security requirements of requested key */
    DM_SM_KEY_TYPE_T key_type;      /* Type of key */

    /* If (key_type == DM_SM_KEY_DIV) then this will be set to the diversifier
       that is required. The application should either reject the request or
       should accept with this value of the diversifier. The application
       should not accept with a different value of the diversifier as that
       is likely to cause an authentication failure.

       In the case of the diversifier, the purpose of this message is to
       indicate to the application that the security manager is about to
       use this particular diversifier to regenerate keys for the given
       device and to get confirmation that this is OK.

       For other types of key, the parameter will be set to zero and shall
       be ignored by the application. */
    uint16_t diversifier;

    /* If (key_type == DM_SM_KEY_ENC_BREDR) then this primitive is being
       used as a direct replacement for the old DM_SM_LINK_KEY_REQUEST_IND.
       The following two parameters are carried across from that primitive.
       For other types of key, the parameters will be set to zero and shall
       be ignored by the application. */
    uint24_t            dev_class; /* Valid for incoming requests 0 otherwise */
    bool_t              initiated_outgoing;
    uint16_t            rhsf;           /* Remote host's supported features */
} DM_SM_KEY_REQUEST_IND_T;

/* Application should only respond with DM_SM_KEY_REQUEST_RSP_T if it has 
 * link key with a matching security_requirements as indicated in 
 * DM_SM_KEY_REQUEST_IND_T. Otherwise DM_SM_KEY_REQUEST_NEG_RSP_T 
 * should be sent.
*/
typedef struct
{
    dm_prim_t type;
    TYPED_BD_ADDR_T addrt;
    uint16_t security_requirements;
    DM_SM_KEY_TYPE_T key_type;
    DM_SM_UKEY_T key;
} DM_SM_KEY_REQUEST_RSP_T;

typedef struct
{
    dm_prim_t type;
    TYPED_BD_ADDR_T addrt;
    DM_SM_KEY_TYPE_T key_type;
} DM_SM_KEY_REQUEST_NEG_RSP_T;

/* The trust level of the remote device. In downstream primitives, this
   is used to change the trust level and any of the three values may be
   used. Setting DM_SM_TRUST_UNCHANGED will not change the trust level.
   (For new device records, this is equivalent to DM_SM_TRUST_DISABLED.)
   In upstream primitives, only DM_SM_TRUST_DISABLED or DM_SM_TRUST_ENABLED
   will be used.

   Untrusted devices result in a DM_SM_AUTHORISE_IND for access to
   protocols that require authorisation.
*/
typedef enum
{
    DM_SM_TRUST_UNCHANGED,  /* Don't change the trust level. */
    DM_SM_TRUST_DISABLED,   /* (make the device) untrusted. */
    DM_SM_TRUST_ENABLED     /* (make the device) trusted. */
} DM_SM_TRUST_T;

typedef enum
{
    DM_SM_PRIVACY_UNCHANGED,/* Keep privacy the way it is. */
    DM_SM_PRIVACY_DISABLED, /* Turn off privacy. */
    DM_SM_PRIVACY_ENABLED   /* Turn on privacy. */
} DM_SM_PRIVACY_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */


/* This API adds a permanent entry to DM SM database.
   If there is already an existing entry to DM SM database,
   make it permanent.
   When 'present' field from keys contains "DM_SM_KEYS_REPLACE_EXISTING" flag,
   this API will clean up the database entry (if already existing)
   completely before replacing with new values.
*/
typedef struct
{
    dm_prim_t           type;       /* Always DM_SM_ADD_DEVICE_REQ */
    phandle_t           phandle;    /* phandle for response */
    TYPED_BD_ADDR_T     addrt;      /* Bluetooth address of remote device */

    /* If privacy is DM_SM_PRIVACY_UNCHANGED then reconnection_bd_addr
       shall be zeroed and will be ignored by Bluestack. Bluestack will
       change neither the privacy state nor the reconnection address
       associated with this remote device.
       If privacy is DM_SM_PRIVACY_DISABLED then reconnection_bd_addr
       shall be zeroed and will be ignored by Bluestack. Bluestack will
       disable privacy for this device and discard any reconnection
       address.
       If privacy is DM_SM_PRIVACY_ENABLED then reconnection_bd_addr shall
       either be zeroed or set to a valid non-resolvable private address.
       Bluestack will enable privacy for this device. If reconnection_bd_addr
       is zeroed then it will discard any reconnection address, otherwise it
       will set the reconnection address to reconnection_bd_addr. */
    DM_SM_PRIVACY_T     privacy;
    BD_ADDR_T           reconnection_bd_addr;

    DM_SM_TRUST_T       trust;      /* Update trust level */
    /*
     * If LE keys needs to be updated(not replaced) in the database then
     * security_requirements field should match with the existing LE keys
     * present in the data base.
    */
    DM_SM_KEYS_T        keys;       /* Security keys and requirements */
} DM_SM_ADD_DEVICE_REQ_T;

typedef struct
{
    dm_prim_t           type;       /* Always DM_SM_ADD_DEVICE_CFM */
    phandle_t           phandle;    /* Destination phandle */
    TYPED_BD_ADDR_T     addrt;
    uint8_t             status;
} DM_SM_ADD_DEVICE_CFM_T;


/* This API gives command to BlueStack to read pairing information
   (for both the transport if pairing has happened)from DM SM device
   Database for the entry related to typed BD ADDR - addrt.
*/
typedef struct
{
    dm_prim_t           type;       /* DM_SM_READ_DEVICE_REQ */
    phandle_t           phandle;    /* phandle for response */
    TYPED_BD_ADDR_T     addrt;
} DM_SM_READ_DEVICE_REQ_T;


/* This API provides SM Database entry information related
   to typed BD ADDR - addrt.
   Note that this confirmation primitive carries information
   for pairing over both the transport (if pairing has happened).
*/
typedef struct
{
    dm_prim_t           type;       /* DM_SM_READ_DEVICE_CFM */
    phandle_t           phandle;    /* Destination phandle */
    TYPED_BD_ADDR_T     addrt;      /* BD_ADDR of device */
    uint8_t             status;
    DM_SM_TRUST_T       trust;      /* Trust level */
    DM_SM_KEYS_T        keys;       /* Security keys and requirements */
} DM_SM_READ_DEVICE_CFM_T;


/* This API removes SM Database entry information related
   to typed BD ADDR - addrt.
   Note that this primitive removes pairing information
   for all the physical transports (if present).
   If the  TYPED BD ADDR- addrt has all octets set to 0xFF,
   then pairing information for all devices in SM database
   shall be removed.
*/
typedef struct
{
    dm_prim_t           type;       /* DM_SM_REMOVE_DEVICE_REQ */
    phandle_t           phandle;    /* phandle for response */
    TYPED_BD_ADDR_T     addrt;
} DM_SM_REMOVE_DEVICE_REQ_T;

typedef struct
{
    dm_prim_t           type;       /* Always DM_SM_ADD_DEVICE_CFM */
    phandle_t           phandle;    /* Destination phandle */
    TYPED_BD_ADDR_T     addrt;
    uint8_t             status;
} DM_SM_REMOVE_DEVICE_CFM_T;

/* Various random private addresses that the controller can be configured to and an
   option to just set controller's RPA timeout.

   Note: DM_SM_ADDRESS_GENERATE_RESOLVABLE and DM_SM_ADDRESS_SET_CONTROLLER_RPA_TIMEOUT
         will set controller's RPA timeout if controller privacy supported.
*/
typedef enum
{
    DM_SM_ADDRESS_WRITE_STATIC,   /* Use included static address */
    DM_SM_ADDRESS_GENERATE_STATIC, /* Generate static address */
    DM_SM_ADDRESS_GENERATE_NON_RESOLVABLE, /* Generate non-resolvable address */
    DM_SM_ADDRESS_GENERATE_RESOLVABLE, /* Generate resolvable address */
    DM_SM_ADDRESS_SET_CONTROLLER_RPA_TIMEOUT /* Set controller's RPA timeout. */
} DM_SM_RANDOM_ADDRESS_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      This API generates a random address of type requested and then sets
 *      the value to controller. The newly generated address and TGAP timer
 *      shall be effective on subsequent scan/adv. There after the random 
 *      address would keep changing at least by TGAP timer time frame.
 *
 *      In case static address is provided by application, it sets the same
 *      static random address to controller if valid, otherwise a new static
 *      address is generated and set with controller. TGAP timer is
 *      not applicable when local address set is static.
 *
 *      Note:
 *      TGAP(private_addr_int) timer shall be implemented below this interface.
 *      The random address generated upon timer expiry is not indicated to the
 *      application.
 *      In case the application requires the local address configured,it can
 *      send DM_SM_READ_RANDOM_ADDRESS_REQ to read the current local
 *      configured address.
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;                       /* DM_SM_AUTO_CONFIGURE_LOCAL_ADDRESS_REQ */
    DM_SM_RANDOM_ADDRESS_T  set_random_addr_type;    /* random address type */
    TP_BD_ADDR_T            static_addrt;               /* Static address from application,
                                                           Transport type would always be LE */
    uint16_t                rpa_timeout;                /* TGAP or rpa timeout in seconds */
} DM_SM_AUTO_CONFIGURE_LOCAL_ADDRESS_REQ_T;

/*-----------------------------------------------------------------------------*
 * PURPOSE
 *      This confirmation provides status of execution of
 *      DM_SM_AUTO_CONFIGURE_LOCAL_ADDRESS_REQ to the application.
 *-----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;       /* DM_SM_AUTO_CONFIGURE_LOCAL_ADDRESS_CFM */
    phandle_t           phandle;    /* am_phandle */
    uint8_t             status;
} DM_SM_AUTO_CONFIGURE_LOCAL_ADDRESS_CFM_T;

/*  The flags below can be set in DM_SM_READ_RANDOM_ADDRESS_REQ_T
 *  to read local or peer rpa.
 */
#define DM_SM_READ_ADDRESS_LOCAL         0x0001
#define DM_SM_READ_ADDRESS_PEER          0x0002

/*-----------------------------------------------------------------------------*
 * PURPOSE
 *      This API handles application's request to read local or peer rpa.
 *      When connected:
 *      If application supplies peer Identity Address then
 *      the function provides local resolvable private address or peer
 *      resolvable private address based on flags set, if the given peer
 *      Identity Address is present.
 *
 *      When not connected: 
 *      Current local configured random address can only be obtained when 
 *      Own_Address_Type has been set as Random Device Address (0x01). 
 *      Here the application needs to set peer Identity address as all zero.
 *      The local configured random address may change based on rpa_timeout
 *      passed in DM_SM_AUTO_CONFIGURE_LOCAL_ADDRESS_REQ when advertising or
 *      scanning is in progress.
 * NOTE:
 *      Current connection address(notified to application) shall be passed as
 *      tp_peer_addrt 
 *-----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;          /* DM_SM_READ_RANDOM_ADDRESS_REQ  */
    TP_BD_ADDR_T        tp_peer_addrt; /* Transport type would always be LE.*/
    uint16_t            flags;         /*  See definition */
} DM_SM_READ_RANDOM_ADDRESS_REQ_T;

/*-----------------------------------------------------------------------------*
 * PURPOSE
 *      This confirmation provides local or peer resolvable private address for
 *      a given peer Identity Address in resolving list.
 *      If the peer Identity address is all zero then the local random address
 *      set to controller is provided.
 *-----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;          /* DM_SM_READ_RANDOM_ADDRESS_CFM */
    phandle_t           phandle;       /* am_phandle */
    uint8_t             status;
    TP_BD_ADDR_T        tp_peer_addrt; /* peer identity address provided in
                                          DM_SM_READ_RANDOM_ADDRESS_REQ */
    uint16_t            flags;         /* See definition */
    TP_BD_ADDR_T        tp_addrt;      /* Local or peer rpa based on flags*/
} DM_SM_READ_RANDOM_ADDRESS_CFM_T;

/*-----------------------------------------------------------------------------*
 * PURPOSE
 *      This API is used to read local device's IRK for a remote device.
 *
 *      Local IRK (Identity Resolving Key) is distributed to remote device
 *      during LE bonding, remote device can resolve local device's random
 *      resolvable address using the local device's IRK. This API shall be used
 *      only after Security Manager is initialized i.e., DM_SM_INIT_CFM
 * 
 * RETURNS
 *      DM_SM_READ_LOCAL_IRK_CFM
 *
 *-----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;       /* DM_SM_READ_LOCAL_IRK_REQ */
    phandle_t           phandle;    /* phandle for response */
    TYPED_BD_ADDR_T     addrt;      /* Remote device's identity address */
} DM_SM_READ_LOCAL_IRK_REQ_T;

/*-----------------------------------------------------------------------------*
 * PURPOSE
 *      This confirmation provides the local IRK for a remote device.
 *
 *      A valid local IRK will be present if the status is HCI_SUCCESS.
 *      Local IRK is packed from LSB to MSB in irk[].
 *-----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;       /* DM_SM_READ_LOCAL_IRK_CFM */
    phandle_t           phandle;    /* Destination phandle */
    TYPED_BD_ADDR_T     addrt;      /* Remote device's identity address */
    uint8_t             status;     /* HCI_SUCCESS or failure */
    uint16_t            irk[8];     /* Local IRK */
} DM_SM_READ_LOCAL_IRK_CFM_T;

/*-----------------------------------------------------------------------------*
 * PURPOSE
 *      The Security Manager asks the application to allow Bluestack to
 *      selectively generate Cross Transport Keys for the indicated
 *      address.
 *
 *      Application may want Bluestack to selectively derive Cross Transport
 *      Keys with remote device. In that case it may override the default
 *      behaviour of Bluestack for generating Cross Transport keys by setting
 *      config bit DM_SM_SEC_MODE_CONFIG_SELECTIVE_CTKD in DM_SM_INIT_REQ.
 *
 *      Once set, DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_IND shall be sent to 
 *      application. Its response "DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_RSP" 
 *      would allow Bluestack to proceed/skip with Cross Transport Keys 
 *      Derivation on given transport with indicated address.
 *
 *  NOTE:
 *   1) Setting DM_SM_SEC_MODE_CONFIG_SELECTIVE_CTKD bit in DM_SM_INIT_REQ
 *      shall enable DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_IND/
 *      DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_RSP interface API
 *      with application. This indication may come if Cross Transport Key
 *      derivation with the remote device is possible.
 *
 *   2) Application NOT setting DM_SM_SEC_MODE_CONFIG_SELECTIVE_CTKD bit in
 *      DM_SM_INIT_REQ shall allow default behaviour of Bluestack generating
 *      Cross Transport Keys as mentioned in DM_SM_IO_CAPABILITY_REQUEST_IND
 *
 *   3) In remote initiated pairing procedure application may receive 
 *      DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_IND and
 *      DM_SM_IO_CAPABILITY_REQUEST_IND concurrently. It is advised to respond
 *      to DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_IND immediately AND before
 *      DM_SM_IO_CAPABILITY_REQUEST_RSP. Remote device may choose to skip CTKD
 *      if the response is delayed or DM_SM_IO_CAPABILITY_REQUEST_RSP is sent
 *      beforehand.
 *-----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;       /* DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_IND_T */
    phandle_t           phandle;    /* Destination phandle */
    TP_BD_ADDR_T        tp_addrt;   /* Remote device's address. The indicated
                                       transport in the request is where the
                                       pairing is being done. The CTKD procedure
                                       would happen to derive the keys of the
                                       other transport.*/
    uint8_t             identifier; /* Unique identifier value the application must copy
                                       into DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_RSP 
                                       when responding to this message on BREDR transport.
                                       On LE transport identifier is reserved*/
    uint16_t            flags;      /* reserved */
} DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_IND_T;

/*  The flags below can be set in DM_SM_GENERATE_CROSS_TRANS_KEY_RSP
 *  to enable or disable Cross transport key derivation.
 */
#define DM_SM_FLAG_GENERATE_CROSS_TRANS_KEY_DISABLE     0x0000
#define DM_SM_FLAG_GENERATE_CROSS_TRANS_KEY_ENABLE      0x0001

/*-----------------------------------------------------------------------------*
 * PURPOSE
 *      This primitive is used to respond to
 *      DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_IND
 *
 *      If the application wants Bluestack to generate Cross Transport Keys then
 *      it shall set flag DM_SM_FLAG_GENERATE_CROSS_TRANS_KEY_ENABLE in the
 *      DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_RSP for 
 *      DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_IND it recieved with indicated
 *      device
 *
 *      If the application sets DM_SM_FLAG_GENERATE_CROSS_TRANS_KEY_DISABLE flag
 *      then Bluestack will not generate Cross Transport Keys for other transport
 *-----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;       /* DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_RSP */
    TP_BD_ADDR_T        tp_addrt;   /* Remote device's address */
    uint8_t             identifier; /* Same value as in
                                       DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_IND */
    uint16_t            flags;      /* See flags definition above */
} DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_RSP_T;

/*-------------------------------------------------------------
 *
 *   CONNECTION PARAMETER CACHE INTERFACE
 *
 *---------------------------------------------------------------*/

/* Cache the page mode parameters for a given bd_addr */
typedef struct
{
    dm_prim_t            type;              /* Always DM_WRITE_CACHED_PAGE_MODE_REQ */
    BD_ADDR_T            bd_addr;           /* Bluetooth device address */
    page_scan_mode_t     page_scan_mode;
    page_scan_rep_mode_t page_scan_rep_mode;
} DM_WRITE_CACHED_PAGE_MODE_REQ_T;

        /* Always DM_WRITE_CACHED_PAGE_MODE_CFM */
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_WRITE_CACHED_PAGE_MODE_CFM_T;

/* Cache the clock offset parameter for a given bd_addr */
typedef struct
{
    dm_prim_t           type;               /* Always DM_WRITE_CACHED_CLOCK_OFFSET_REQ */
    BD_ADDR_T           bd_addr;            /* Bluetooth device address */
    uint16_t            clock_offset;       /* the clock offset */
} DM_WRITE_CACHED_CLOCK_OFFSET_REQ_T;

        /* Always DM_WRITE_CACHED_CLOCK_OFFSET_CFM */
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_WRITE_CACHED_CLOCK_OFFSET_CFM_T;

/* Clear all cached parameters for a given bd_addr */
typedef struct
{
    dm_prim_t           type;               /* Always DM_CLEAR_PARAM_CACHE_REQ */
    BD_ADDR_T           bd_addr;            /* Bluetooth device address */
} DM_CLEAR_PARAM_CACHE_REQ_T;

        /* Always DM_CLEAR_PARAM_CACHE_CFM */
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_CLEAR_PARAM_CACHE_CFM_T;

/*-------------------------------------------------------------
 *
 *   BLACK LIST HANDLING INTERFACE
 *
 *---------------------------------------------------------------*/
#define DM_BLACK_LIST_REMOVE_ALL_DEVICES          0x0000
#define DM_BLACK_LIST_ADD_DEVICE                  0x0001
#define DM_BLACK_LIST_REMOVE_DEVICE               0x0002

/* ADD/REMOVE/REMOVE ALL devices in/from blacklist */
typedef struct
{
    dm_prim_t              type;              /* Always DM_HANDLE_DEVICE_BLACK_LIST_REQ */
    TYPED_BD_ADDR_T        addrt;             /* Bluetooth device address and Type */
    uint16_t               flags;             /*  Additional falgs ADD/REMOVE/REMOVE ALL */
} DM_HANDLE_DEVICE_BLACK_LIST_REQ_T;

#define DM_BLACK_LIST_CFM_SUCCESS                       0x00
#define DM_BLACK_LIST_CFM_MEMORY_FULL                   0x01
#define DM_BLACK_LIST_CFM_DEVICE_ALREADY_IN_LIST        0x02
#define DM_BLACK_LIST_CFM_EXCEEDED_NO_OF_DEVICES        0x03
#define DM_BLACK_LIST_CFM_ILLEGAL_OPERATION             0xff
/* Confirmation event DM_HANDLE_DEVICE_BLACK_LIST_REQ*/
typedef struct
{
    dm_prim_t               type;         /* Always DM_HANDLE_DEVICE_BLACK_LIST_CFM */
    TYPED_BD_ADDR_T         addrt;        /* Bluetooth device address */
    uint8_t                 status;       /* status */
} DM_HANDLE_DEVICE_BLACK_LIST_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Request from Application task for the DM to create an ACL to the
 *      specified remote device. This might be used for pairing, for example.
 *      The DM allows both L2CAP and the application to request ACLs.
 *      The DM keeps track of who has an interest in
 *      each ACL, and will only disconnect the ACL when all interested parties
 *      have released the ACL (by DM_ACL_CLOSE_REQ).
 *
 *      DM_ACL_OPEN_REQ registers the application's interest in the ACL. DM will
 *      create the link if it does not already exist. DM will always respond
 *      with DM_ACL_OPEN_CFM, indicating success or failure. If successful, the
 *      application may subsequently call DM_ACL_CLOSE_REQ to relinquish its
 *      interest in the ACL - DM will then release the link if L2CAP is not
 *      using it.
 *
 *      The DM keeps the application informed of the state of all ACLs via the
 *      DM_ACL_OPENED_IND and DM_ACL_CLOSED_IND primitives.
 *
 *----------------------------------------------------------------------------*/

/* Bitfield of options

   Bit 0     DM_ACL_FLAG_INCOMING
             Will be set in DM_ACL_OPENED_IND and DM_ACL_CLOSED_IND primitives
             if the ACL was created by the remote device. It shall be set to
             0 in DM_ACL_OPEN_REQ, DM_ACL_CLOSE_REQ, DM_SM_BONDING_REQ and
             DM_SM_BONDING_CANCEL_REQ.
             Note: During connection collision for link establishment with a
             peer device the incoming connection will be accepted and the
             outgoing connection will be dropped,
             hence this bit will be set in DM_ACL_OPENED_IND for this scenario.
             Since there is an outgoing connection request, application will be
             notified with DM_ACL_OPEN_CFM.

   Bit 1     DM_ACL_FLAG_ALL
             Indicates that request should apply to all existing connections.
             If this is set then any Bluetooth address in the primitives will be
             ignored. This shall be set to 0 in DM_ACL_OPEN_REQ,
             DM_SM_BONDING_REQ and DM_SM_BONDING_CANCEL_REQ and will be
             set to 0 in DM_ACL_OPENED_IND and DM_ACL_CLOSED_IND.

   Bit 2     DM_ACL_FLAG_FORCE
             Indicates that a more aggressive version of the command should
             be used. This shall be set to 0 in DM_ACL_OPEN_REQ,
             DM_SM_BONDING_REQ and will be set to 0 in DM_ACL_OPENED_IND and
             DM_ACL_CLOSED_IND. If set in DM_ACL_CLOSE_REQ then the ACL will
             be disconnected irrespective of any L2CAP connections that are
             active. If set in DM_SM_BONDING_CANCEL_REQ then, if all else
             fails, the device manager will cancel bonding by bringing down
             the ACL, even if there are active L2CAP connections.

   Bit 3     DM_ACL_FLAG_ULP
             Indicates that request shall be set for BLE connection and
             Will be set in upstream primitives for BLE connection.
             Use Bit 5:7 in DM_ACL_OPEN_REQ for special LE connection procedures.

   Bit 4     DM_ACL_FLAG_ULP_RRPA_RESOLVED
             Significant to DM_ACL_OPENED_IND for LE transport only on OFFCHIP
             implementation. 
             If set, then it implies that peer's resolvable random private
             address (RRPA) is resolved based on the keys added to SM device
             database by application. 
             In ONCHIP its always set to 0.

   Bit 5:7  Significant to DM_ACL_OPEN_REQ and not applicable for other primitives.
            Special LE connection flags when DM_ACL_FLAG_ULP (bit 3) is set
            and imply the following behavior:
            <    Binary    >  <                    Description                >
                001x1xxx        RFU, shall not be used
                010x1xxx        Connect as Master
                011x1xxx        Connect as Master using acceptor list
                100x1xxx        RFU, shall not be used
                101x1xxx        RFU, shall not be used
                110x1xxx        RFU, shall not be used
                111x1xxx        RFU, shall not be used

             Note: if acceptor list connection flag is used then the 'addrt'
             in the DM_ACL_OPEN_REQ will be ignored and connections will be
             processed only from the devices in the acceptor list.

   Bits 8-15 Reserved
             Shall be set to 0.
*/
#define DM_ACL_FLAG_INCOMING                    0x0001
#define DM_ACL_FLAG_ALL                         0x0002
#define DM_ACL_FLAG_FORCE                       0x0004
#define DM_ACL_FLAG_ULP                         0x0008
#define DM_ACL_FLAG_ULP_RRPA_RESOLVED           0x0010
#define DM_ACL_FLAG_ULP_CONNECT_AS_MASTER       (0x0040 | DM_ACL_FLAG_ULP)
#define DM_ACL_FLAG_ULP_CONNECT_ACCEPTOR_LIST   (0x0060 | DM_ACL_FLAG_ULP)
#define DM_ACL_LE_CONNECTION_FLAG_MASK          0x00E0   /* Bits 5:7 for LE connection flags */

typedef struct
{
    dm_prim_t               type;           /* Always DM_ACL_OPEN_REQ */
    TYPED_BD_ADDR_T         addrt;          /* Remote device address */
    uint16_t                flags;          /* Bitfield of options */
} DM_ACL_OPEN_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Confirmation of an application request to create an ACL. See text for
 *      DM_ACL_OPEN_REQ for more details.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;           /* Always DM_ACL_OPEN_CFM */
    phandle_t               phandle;        /* Destination phandle */
    TYPED_BD_ADDR_T         addrt;          /* Remote device address */
    bool_t                  success;        /* TRUE if open, FALSE if not */
} DM_ACL_OPEN_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Request from the application to close the ACL to the specified device.
 *      An application may send this request for the ACLs which are established.
 *
 *      Application will be notified with DM_ACL_CLOSED_CFM primitive once the
 *      close operation is finished.
 *
 *      If DM_ACL_FLAG_ALL is set, then confirmation to the application
 *      will be sent after all the ACLs are disconnected.
 *      Note: If this flag is set then any Bluetooth address will be ignored.
 *
 *      If DM_ACL_FLAG_FORCE is not set, then disconnection will be processed
 *      only when all channels using ACL is closed. Bluestack will send the
 *      DM_ACL_CLOSE_CFM only after ACL is disconnected. Applications should
 *      be aware of this behavior.
 *
 *      If there is a pending close request for an ACL link, then any subsequent
 *      close request from application for the same BD Address will be rejected
 *      with DM_ACL_CLOSE_BUSY. In case the new close request has flag
 *      DM_ACL_FLAG_FORCE additionally then the former request will get
 *      overridden and one DM_ACL_CLOSE_CFM shall be sent to application
 *      when ACL link is closed.
 *
 *      DM_ACL_CLOSED_IND primitive is issued for each ACL when it is closed,
 *      but the DM may keep the ACL open if L2CAP is still using it.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;      /* Always DM_ACL_CLOSE_REQ */
    TYPED_BD_ADDR_T         addrt;     /* Remote device address */
    uint16_t                flags;     /* See definitions for DM_ACL_OPEN_REQ */
    hci_reason_t            reason;    /* Only used if 'FORCE' flag set */
} DM_ACL_CLOSE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Confirmation to an application request (DM_ACL_CLOSE_REQ) to disconnect
 *      the established ACL.
 *      addrt will set to zero if DM_ACL_FLAG_ALL is set in DM_ACL_CLOSE_REQ.
 *----------------------------------------------------------------------------*/
#define DM_ACL_CLOSE_SUCCESS                ((uint8_t)0) /* ACL close Success */
#define DM_ACL_CLOSE_BUSY                   ((uint8_t)1) /* ACL close in progress with peer*/
#define DM_ACL_CLOSE_NO_CONNECTION          ((uint8_t)2) /* NO ACL connection with peer */
#define DM_ACL_CLOSE_LINK_TRANSFERRED       ((uint8_t)3) /* ACL link transferred */
#define DM_ACL_CLOSE_EXISTING_LINKS_CLOSED  ((uint8_t)4) /* Existing ACL links are closed */

typedef struct
{
    dm_prim_t               type;      /* Always DM_ACL_CLOSE_CFM */
    phandle_t               phandle;   /* Destination phandle */
    TYPED_BD_ADDR_T         addrt;     /* Peer device address */
    uint16_t                flags;     /* Same as DM_ACL_CLOSE_REQ */
    uint8_t                 status;    /* Success or failure */
} DM_ACL_CLOSE_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Letting higher layers know about ACL comings and goings. This primitive
 *      is issued to the application interface whenever an ACL is successfully
 *      established (incoming or outgoing).
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;           /* Always DM_ACL_OPENED_IND */
    phandle_t               phandle;        /* Destination phandle */
    TYPED_BD_ADDR_T         addrt;          /* Peer device address */

    /* See definitions for DM_ACL_OPEN_REQ */
    uint16_t                flags;

    /* Class of device for peer, valid for incoming connections only */
    uint24_t                dev_class;
    hci_return_t            status;         /* Indication of success or failure. */

    /* Parameters valid when status is HCI_SUCCESS and 'flags' has DM_ACL_FLAG_ULP set*/
    DM_ACL_BLE_CONN_PARAMS_T  ble_conn_params;

} DM_ACL_OPENED_IND_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Indicates higher layers that the ACL Connection request has been
 *      sent to lower layers. This primitive is used indicate that lower
 *      layer may start paging, to connect remote device. The primitive
 *      is under INSTALL_BUILD_FOR_HOST_DM_ACL_CON_START_IND.

 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;      /* Always DM_ACL_CONN_START_IND */
    phandle_t               phandle;   /* Destination phandle */
    TYPED_BD_ADDR_T         addrt;     /* Peer device address */
    uint16_t                flags;     /* See definitions for DM_ACL_OPEN_REQ*/
} DM_ACL_CONN_START_IND_T;


/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Letting higher layers know about ACL comings and goings. This primitive
 *      is issued (as a replacement of DM_ACL_OPENED_IND) under
 *      INSTALL_BUILD_FOR_HOST_DM_ACL_CON_HANDLE_IND switch whenever an ACL is
 *      successfully established (incoming or outgoing) along with acl handle.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;           /* Always DM_ACL_CONN_HANDLE_IND */
    phandle_t               phandle;        /* Destination phandle */
    TYPED_BD_ADDR_T         addrt;          /* Peer device address */

    /* See definitions for DM_ACL_OPEN_REQ */
    uint16_t                flags;

    /* Class of device for peer, valid for incoming connections only */
    uint24_t                dev_class;
    hci_return_t            status;         /* Indication of success or failure. */

    /* Parameters valid when status is HCI_SUCCESS and 'flags' has DM_ACL_FLAG_ULP set*/
    DM_ACL_BLE_CONN_PARAMS_T  ble_conn_params;

    /* ACL connection handle */
    uint16_t                acl_conn_handle;
} DM_ACL_CONN_HANDLE_IND_T;


/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Letting higher layers know about ACL comings and goings. This primitive
 *      is issued to the application interface whenever a successfully
 *      established ACL is disconnected.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;      /* Always DM_ACL_CLOSED_IND */
    phandle_t               phandle;   /* Destination phandle */
    TYPED_BD_ADDR_T         addrt;     /* Peer device address */
    hci_error_t             reason;    /* Reason */
    uint16_t                flags;     /* See definitions for DM_ACL_OPEN_REQ */
} DM_ACL_CLOSED_IND_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Define the default link policy to be applied to all new connections.
 *      This does not affect existing connections.
 *
 *      For valid policy settings see 'HCI Link Policy Settings' in hci.h.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;           /* Always DM_SET_DEFAULT_LINK_POLICY_REQ */

    /* Link Manager policy settings for incoming and outgoing connections */
    link_policy_settings_t  link_policy_settings_in;
    link_policy_settings_t  link_policy_settings_out;
} DM_SET_DEFAULT_LINK_POLICY_REQ_T;

/* Link behavior configuration key */
/* 
 * DM_LINK_BEHAVIOR_L2CAP_RETRY: It is L2CAP retry Key. This key expects the
 * device to be present in the SM-DB as a pre-condition, else the prim 
 * DM_SET_LINK_BEHAVIOR_REQ_T would throw the error 
 * DM_SET_LINK_BEHAVIOR_DEVICE_NOT_FOUND.
 * 
 * While the device is present in SM-DB, the application shall be able to set 
 * this key-value. This would be applicable to all subsequent L2CAP channel 
 * creation with that device.
 * 
 * The application shall be able to set the key-value for the same device 
 * multiple times.
 */
#define DM_LINK_BEHAVIOR_L2CAP_RETRY        ((uint16_t)0x0001)

/* Link behavior configuration values */

/* While L2CAP channel creation(locally initiated) is in progress and the ACL 
 * link is closed, then bluestack shall estbalish ACL link first and then 
 * create L2CAP channel.
 */
#define DM_LINK_BEHAVIOR_L2CAP_RETRY_ON     ((uint16_t)TRUE)
/* While L2CAP channel creation(locally initiated) is in progress and the ACL 
 * link is closed, then L2CAP shall return an error for the channel creation 
 * procedure.
 */
#define DM_LINK_BEHAVIOR_L2CAP_RETRY_OFF    ((uint16_t)FALSE)

/* Link behavior configuration key */
/* 
 * DM_LINK_BEHAVIOR_APP_HANDLE_L2CAP_PING: Enables the application to handle 
 * the L2CAP_PING_REQ from remote device and frame the response.
 * 
 * While the device is present in SM-DB, the application shall be able to set 
 * this key-value.
 * 
 * The application shall be able to set the key-value for the same device 
 * multiple times.
 */
#define DM_LINK_BEHAVIOR_APP_HANDLE_L2CAP_PING  ((uint16_t)0x0002)

/* Link behavior configuration values for L2CAP PING */

/* Lets the application handle the L2CAP_PING_REQ and frame the L2CAP_PING_RSP. */
#define DM_LINK_BEHAVIOR_APP_HANDLE_L2CAP_PING_ON  ((uint16_t)TRUE)

/* The L2CAP_PING_REQ shall be handled internally and response shall be sent 
 * to remote device.
 */
#define DM_LINK_BEHAVIOR_APP_HANDLE_L2CAP_PING_OFF ((uint16_t)FALSE)

/* Link behavior configuration key */
/* 
 * DM_LINK_BEHAVIOR_DONT_ESTABLISH_ACL_ON_L2CAP_CONNECT: When the application 
 * requests for L2CAP or RFCOMM or SDP connection, QBL shall not attempt to 
 * establish an ACL connection if not already there, instead return failure.
 * 
 * When this key is enabled, the application needs to ensure ACL connection 
 * before requesting for any profile level connection.
 *
 * While the remote device entry is present in SM-DB, the application shall be 
 * able to set this key-value. This would be applicable to all subsequent L2CAP 
 * connect request with that device. This configuration is only applicable on 
 * BREDR transport.
 * 
 * The application shall be able to set the key-value for the same device 
 * multiple times.
 */
#define DM_LINK_BEHAVIOR_DONT_ESTABLISH_ACL_ON_L2CAP_CONNECT  ((uint16_t)0x0003)

/* Link behavior configuration values for Creating ACL Link on L2CAP Connect 
 * Request.
 */

/* When the application requests for L2CAP Connection, and if ACL is not connected,
 * then QBL would not establish the ACL and would return an error.
 */
#define DM_LINK_BEHAVIOR_DONT_ESTABLISH_ACL_ON_L2CAP_CONNECT_ON     ((uint16_t)TRUE)

/* When the application requests for L2CAP Connection, and if ACL is not connected,
 * then QBL would attempt to establish the ACL. This is the default behavior.
 */
#define DM_LINK_BEHAVIOR_DONT_ESTABLISH_ACL_ON_L2CAP_CONNECT_OFF    ((uint16_t)FALSE)

/* Link behavior configuration key */
/* 
 * DM_LINK_BEHAVIOR_REJECT_RFCOMM_DURING_DLC_CREATION: When the remote device 
 * initiates parameter negotiation for creating the DLC and if the application 
 * delcines the same, the RFCOMM module based on this configuration shall decide 
 * to send the disconnect to remote device either during initial parameter 
 * negotiation phase or during DLC creation.
 * 
 * When this key is enabled, the application needs to ensure ACL connection 
 * before requesting for any profile level connection.
 *
 * While the remote device entry is present in SM-DB, the application shall be 
 * able to set this key-value. This would be applicable to all subsequent RFCOMM 
 * connect request with that device. This configuration is only applicable on 
 * BREDR transport.
 *
 * By default the DM_LINK_BEHAVIOR_REJECT_RFCOMM_DURING_DLC_CREATION_OFF is set.
 * 
 * The application shall be able to set the key-value for the same device 
 * multiple times.
 */
#define DM_LINK_BEHAVIOR_REJECT_RFCOMM_DURING_DLC_CREATION  ((uint16_t)0x0004)

/* Link behavior configuration values for Rejecting the DLC creation.
 */

/* When the RFCOMM receives RFC_SERVER_CONNECT_RSP with response set to value 
   other than RFC_ACCEPT_SERVER_CONNECTION, then RFCOMM shall reject the DLC 
   connection during the creation of DLC and not during the initial parameter 
   negotiation.
 */
#define DM_LINK_BEHAVIOR_REJECT_RFCOMM_DURING_DLC_CREATION_ON     ((uint16_t)TRUE)

/* When the RFCOMM receives RFC_SERVER_CONNECT_RSP with response set to value
   other than RFC_ACCEPT_SERVER_CONNECTION, then RFCOMM shall reject the DLC 
   connection during the initial parameter negotiation.
 */
#define DM_LINK_BEHAVIOR_REJECT_RFCOMM_DURING_DLC_CREATION_OFF    ((uint16_t)FALSE)

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Define the link behavior to be applied to new connections.
 *      This does not affect existing connections.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;           /* Always DM_SET_LINK_BEHAVIOR_REQ */

    /* Link behavior configuration settings request data */
    TYPED_BD_ADDR_T         addrt;          /* Device address */
    uint16_t                conftab_length; /* Number of uint16_t's in the 'conftab' table */
    /**
    * Configuration table Ex:
    * conftab_length = 6
    * conftab[0] = 0x8000                               //SEPARATOR
    * conftab[1] = DM_LINK_BEHAVIOR_L2CAP_RETRY         //Key
    * conftab[2] = DM_LINK_BEHAVIOR_L2CAP_RETRY_ON      //Value
    * conftab[3] = New-Key                              //Key
    * conftab[4] = New-Value                            //Value
    * conftab[5] = 0xFF00                               //BARRIER
    **/
    uint16_t                *conftab;       /* Configuration table (key,value pairs) */
} DM_SET_LINK_BEHAVIOR_REQ_T;

/* Set Link behavior status values */
#define DM_SET_LINK_BEHAVIOR_SUCCESS                    0x00
#define DM_SET_LINK_BEHAVIOR_DEVICE_NOT_FOUND           0x01
#define DM_SET_LINK_BEHAVIOR_INVALID_CONFTAB            0x02
#define DM_SET_LINK_BEHAVIOR_INVALID_KEY_OR_VALUE       0x03
#define DM_SET_LINK_BEHAVIOR_FAILURE                    0xFF

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Confirmation of an application request to set the link behavior. See text 
 *      for DM_SET_LINK_BEHAVIOR_REQ for more details.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;           /* Always DM_SET_LINK_BEHAVIOR_CFM */
    phandle_t               phandle;        /* Destination phandle */

    /* Link behavior configuration settings confirmation data */
    TYPED_BD_ADDR_T         addrt;          /* Device address */
    uint8_t                 status;         /* Success or failure */
} DM_SET_LINK_BEHAVIOR_CFM_T;

/*
 * Internal DM/AMPM Interface.
 */

/* Tell the DM how to contact the AMPM. I guess we don't need this if the
   DM is compiled to know where AMPM is found, but having it makes things
   more flexible. We could test the DM's AMPM interface from rfcli, or
   even have an AMPM in the VM.

            AMPM                                         DM
                        DM_AMPM_REGISTER_REQ
            --------------------------------------------->
                        DM_AMPM_REGISTER_CFM
            <---------------------------------------------
*/
typedef struct
{
    dm_prim_t       type;       /* Always DM_AMPM_REGISTER_REQ */
    phandle_t       phandle;    /* AMPM Message Queue ID */
} DM_AMPM_REGISTER_REQ_T;

typedef struct
{
    dm_prim_t       type;       /* Always DM_AMPM_REGISTER_CFM */
    phandle_t       phandle;    /* AMPM Message Queue ID */
} DM_AMPM_REGISTER_CFM_T;




/* Copy of DM_SM_LINK_KEY_IND_T to be sent to AMPM. Whenever the DM gets
   HCI_EV_LINK_KEY_NOTIFICATION, it passes DM_SM_LINK_KEY_IND up to the
   application. While it is doing that, it can just make a copy, change
   the 'type' field to DM_AMPM_LINK_KEY_NOTIFICATION_IND and send to AMPM.

            AMPM                                         DM
                    DM_AMPM_LINK_KEY_NOTIFICATION_IND
            <---------------------------------------------
*/
typedef DM_SM_LINK_KEY_IND_T DM_AMPM_LINK_KEY_NOTIFICATION_IND_T;




/* DM tells AMPM about need for physical connection. This happens after
   l2cap receives a connect request from a higher layer and after the ACL
   is up and encryption has been enabled, but before any l2cap connection
   signalling. On the initiating side, the AMPM will receive one of these
   for every l2cap channel to be connected, irrespective of whether or not
   the required physical connection exists. This is not sent on the responding
   side as by the time the responder knows about the l2cap connection, the
   physical channel is already connected.

            AMPM                                         DM
                        DM_AMPM_CONNECT_IND
            <---------------------------------------------
                        DM_AMPM_CONNECT_RSP
            --------------------------------------------->
*/
typedef struct
{
    dm_prim_t           type;           /* Always DM_AMPM_CONNECT_IND */
    phandle_t           phandle;        /* AMPM Message Queue ID */
    BD_ADDR_T           bd_addr;        /* Remote Bluetooth Address */
    l2ca_cid_t          cid;
    l2ca_controller_t   local_amp_id;
    l2ca_controller_t   remote_amp_id;
} DM_AMPM_CONNECT_IND_T;


typedef struct
{
    dm_prim_t           type;           /* Always DM_AMPM_CONNECT_RSP */
    BD_ADDR_T           bd_addr;        /* Remote Bluetooth Address */
    l2ca_cid_t          cid;            /* l2cap channel ID */
    l2ca_controller_t   local_amp_id;
    l2ca_controller_t   remote_amp_id;
    hci_return_t        status;         /* Anything other than 0 is failure */
} DM_AMPM_CONNECT_RSP_T;




/* DM tells AMPM about need for logical connection. This is sent after the
   l2cap connection and configuration signalling has successfully completed.
   AMPM is passed the final flow spec and is given the signal to establish
   a logical link. The AMPM will receive one of these for every l2cap
   channel to be connected even if the channel can be put on an existing
   logical link.
            AMPM                                         DM
                     DM_AMPM_CONNECT_CHANNEL_IND
            <---------------------------------------------
                     DM_AMPM_CONNECT_CHANNEL_RSP
            --------------------------------------------->
*/
typedef struct
{
    dm_prim_t               type;           /* DM_AMPM_CONNECT_CHANNEL_IND */
    phandle_t               phandle;        /* AMPM Message Queue ID */
    hci_connection_handle_t handle;         /* HCI connection handle */
    BD_ADDR_T               bd_addr;        /* Remote Bluetooth Address */
    l2ca_cid_t              cid;            /* l2cap channel ID */
    l2ca_controller_t       local_amp_id;
    L2CA_FLOWSPEC_T         tx_flowspec;   /* TX QOS parameters */
    L2CA_FLOWSPEC_T         rx_flowspec;   /* RX QOS parameters */
} DM_AMPM_CONNECT_CHANNEL_IND_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef struct
{
    dm_prim_t           type;            /* DM_AMPM_CONNECT_CHANNEL_RSP */
    BD_ADDR_T           bd_addr;         /* Remote Bluetooth Address */
    l2ca_cid_t          cid;             /* l2cap channel ID */
    l2ca_controller_t   local_amp_id;    /* AMP ID */
    uint8_t             physical_link_id;/* AMP physical handle */
    amp_link_id_t       logical_link_id; /* AMP logical handle */
    phandle_t           hci_data_queue;  /* Where L2CAP sends to-air data */
    L2CA_FLOWSPEC_T     tx_flowspec;     /* TX QOS parameters */
    L2CA_FLOWSPEC_T     rx_flowspec;     /* RX QOS parameters */
    hci_return_t        status;          /* Anything other than 0 is failure */
} DM_AMPM_CONNECT_CHANNEL_RSP_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

/* What follows is temporary stuff to allow the use of primitives equivalent
 * to the above in Rfcli. The problem is the repeated L2CA_FLOWSPEC_T
 * structures. Rfcli names its functions after the elements of the structures
 * and so we get duplicate function names, which annoys the compiler.
 * So we define equivalent primitives below that don't annoy Rfcli.
 */
typedef struct
{
    l2ca_fs_identifier_t   rx_fs_identifier;
    l2ca_fs_service_t      rx_fs_service_type;
    l2ca_fs_mtu_t          rx_fs_max_sdu;
    l2ca_bandwidth_t       rx_fs_interarrival;
    l2ca_latency_t         rx_fs_latency;
    l2ca_fs_flush_t        rx_fs_flush_to;
} L2CA_RX_FLOWSPEC_T;/* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT)*/
typedef struct
{
    dm_prim_t           type;           /* DM_AMPM_CONNECT_CHANNEL_IND */
    phandle_t           phandle;        /* AMPM Message Queue ID */
    hci_connection_handle_t handle;     /* HCI connection handle */
    BD_ADDR_T           bd_addr;        /* Remote Bluetooth Address */
    l2ca_cid_t          cid;            /* l2cap channel ID */
    l2ca_controller_t   local_amp_id;
    L2CA_FLOWSPEC_T     tx_flowspec;   /* TX QOS parameters */
    L2CA_RX_FLOWSPEC_T  rx_flowspec;   /* RX QOS parameters */
} DM_AMPM_CONN_CHANNEL_IND_T;
typedef struct
{
    dm_prim_t           type;            /* DM_AMPM_CONNECT_CHANNEL_RSP */
    l2ca_cid_t          cid;             /* l2cap channel ID */
    l2ca_controller_t   local_amp_id;    /* AMP ID */
    uint8_t             physical_link_id;/* AMP physical handle */
    amp_link_id_t       logical_link_id; /* AMP logical handle */
    phandle_t           hci_data_queue;  /* Where L2CAP sends to-air data */
    L2CA_FLOWSPEC_T     tx_flowspec;     /* TX QOS parameters */
    L2CA_RX_FLOWSPEC_T  rx_flowspec;     /* RX QOS parameters */
    hci_return_t        status;          /* Anything other than 0 is failure */
} DM_AMPM_CONN_CHANNEL_RSP_T;
#define DM_AMPM_CONN_CHANNEL_IND DM_AMPM_CONNECT_CHANNEL_IND
#define DM_AMPM_CONN_CHANNEL_RSP DM_AMPM_CONNECT_CHANNEL_RSP
/* End of Rfcli workaround */

/* DM tells AMPM about closed l2cap channel. When ever an l2cap channel is
   disconnected, the AMPM will receive one of these.
            AMPM                                         DM
                    DM_AMPM_DISCONNECT_CHANNEL_IND
            <---------------------------------------------
                    DM_AMPM_DISCONNECT_CHANNEL_RSP
            --------------------------------------------->
*/
typedef struct
{
    dm_prim_t           type;           /* DM_AMPM_DISCONNECT_CHANNEL_IND */
    phandle_t           phandle;        /* AMPM Message Queue ID */
    l2ca_cid_t          cid;            /* l2cap channel ID */
    l2ca_controller_t   local_amp_id;
} DM_AMPM_DISCONNECT_CHANNEL_IND_T;

typedef struct
{
    dm_prim_t           type;           /* DM_AMPM_DISCONNECT_CHANNEL_RSP */
    l2ca_cid_t          cid;            /* l2cap channel ID */
    l2ca_controller_t   local_amp_id;
    hci_return_t        status;         /* Anything other than 0 is failure */
} DM_AMPM_DISCONNECT_CHANNEL_RSP_T;




/* AMPM tells DM about link loss.

            AMPM                                         DM
                        DM_AMPM_DISCONNECT_REQ
            --------------------------------------------->
*/
typedef struct
{
    dm_prim_t           type;           /* Always DM_AMPM_DISCONNECT_REQ */
    BD_ADDR_T           bd_addr;        /* Remote Bluetooth Address */
    l2ca_controller_t   local_amp_id;
    hci_error_t         reason;         /* Reason for disconnect. */
    uint8_t             active_links;   /* Number of active links remaining */
} DM_AMPM_DISCONNECT_REQ_T;


/* AMPM reads the local Bluetooth address. */
typedef struct
{
    dm_prim_t           type;       /* Always DM_READ_BD_ADDR_REQ */
} DM_AMPM_READ_BD_ADDR_REQ_T;

typedef struct
{
    dm_prim_t           type;       /* Always DM_READ_BD_ADDR_CFM */
    phandle_t           phandle;    /* AMPM Message Queue ID */
    uint8_t             status;     /* Anything other than 0 is failure */
    BD_ADDR_T           bd_addr;    /* Local Bluetooth address */
} DM_AMPM_READ_BD_ADDR_CFM_T;

/* DM asks AMPM about whether a physical link (given by the local
 * controller ID) actually exists */
typedef struct
{
    dm_prim_t           type;         /* Always DM_AMPM_VERIFY_PHYSICAL_LINK_IND */
    phandle_t           phandle;      /* AMPM Message Queue ID */
    BD_ADDR_T           bd_addr;      /* Remote Bluetooth address */
    uint16_t            identifier;   /* Request identifier to match up with CFM */
    l2ca_controller_t   local_amp_id; /* Local AMP controller ID */
} DM_AMPM_VERIFY_PHYSICAL_LINK_IND_T;

typedef struct
{
    dm_prim_t           type;         /* Always DM_AMPM_VERIFY_PHYSICAL_LINK_RSP */
    BD_ADDR_T           bd_addr;      /* Remote Bluetooth address */
    uint16_t            identifier;   /* Identifier given in the REQ */
    bool_t              exists;       /* TRUE if link exists, FALSE if not */
    l2ca_fs_flush_t     link_supervision_timeout;  /* AMP LSTO - unit is in microseconds */
    l2ca_fs_flush_t     best_effort_flush_timeout; /* Default flush - uint is in microseconds */
} DM_AMPM_VERIFY_PHYSICAL_LINK_RSP_T;

/* DM requests Buffer size information from AMPM */
typedef struct
{
    dm_prim_t           type;                       /* Always DM_AMPM_READ_DATA_BLOCK_SIZE_IND */
    phandle_t           phandle;                    /* AMPM Message Queue ID */
    l2ca_controller_t   local_amp_id;               /* Local AMP controller ID */
} DM_AMPM_READ_DATA_BLOCK_SIZE_IND_T;

typedef struct
{
    dm_prim_t           type;                       /* Always DM_AMPM_READ_DATA_BLOCK_SIZE_RSP_T */
    l2ca_controller_t   local_amp_id;               /* Local AMP controller ID */
    uint8_t             status;                     /* Anything other than 0 is failure */
    bool_t              fragmentable;               /* Whether we can fragment packets over HCI */
    uint16_t            max_pdu_length;             /* Maximum l2cap PDU size */
    uint16_t            max_acl_data_packet_length; /* Maximum size of ACL data packets over HCI */
    uint16_t            data_block_length;          /* Size of data blocks */
    uint16_t            total_num_data_blocks;      /* Total number of data blocks */
} DM_AMPM_READ_DATA_BLOCK_SIZE_RSP_T;

/* Handle/Complete structure for returning credits. */
typedef struct
{
    amp_link_id_t       logical_link_handle;
    uint16_t            num_of_completed_packets;
    uint16_t            num_of_completed_blocks;
} DM_AMPM_NCB_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

/* Calculate how many pointers we might need. */
#define DM_AMPM_NCB_HCI_BYTE_SIZE           6
#define DM_AMPM_NCB_XAP_SIZE                6
#define DM_AMPM_HANDLE_COMPLETES_PER_PTR    (HCI_VAR_ARG_POOL_SIZE/DM_AMPM_NCB_XAP_SIZE)
#define DM_AMPM_NUM_COMPLETED_BLOCKS_PTRS   ((254/DM_AMPM_NCB_HCI_BYTE_SIZE + DM_AMPM_HANDLE_COMPLETES_PER_PTR - 1) \
                                                / DM_AMPM_HANDLE_COMPLETES_PER_PTR)

/* AMPM informs DM of number of completed data blocks events */
typedef struct
{
    dm_prim_t           type;                       /* Always DM_AMPM_NUMBER_COMPLETED_DATA_BLOCKS_REQ */
    l2ca_controller_t   local_amp_id;               /* Local AMP controller ID */
    uint16_t            total_num_data_blocks;      /* Change total number of credits. Maximum reduction equal to credits
                                                       returned by this primitive. 0 means: Send me a new
                                                       DM_AMPM_READ_DATA_BLOCK_SIZE_IND */
    uint8_t             number_of_handles;          /* Total number of handles referenced by this primitive */

    DM_AMPM_NCB_T       *num_completed_blks_ptr[DM_AMPM_NUM_COMPLETED_BLOCKS_PTRS];
} DM_AMPM_NUMBER_COMPLETED_DATA_BLOCKS_REQ_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

/* DM informs AMPM when it's in Security Mode 4 */
typedef struct
{
    dm_prim_t type;
    phandle_t phandle;
} DM_AMPM_SIMPLE_PAIRING_ENABLED_IND_T;

/* DM informs AMPM of relevant remote supported features */
#define DM_AMPM_REMOTE_FEATURES_NONE    0x0000  /* Nothing supported. */
#define DM_AMPM_REMOTE_FEATURES_SSP     0x0001  /* Full Secure Simple Pairing
                                                   support (controller+host) */
typedef struct
{
    dm_prim_t type;                     /* DM_AMPM_REMOTE_FEATURES_IND */
    phandle_t phandle;                  /* AMPM Message Queue ID */
    BD_ADDR_T bd_addr;                  /* Remote device Bluetooth address */
    uint16_t flags;                     /* Feature bitfield. See above. */
} DM_AMPM_REMOTE_FEATURES_IND_T;



typedef struct {
    dm_prim_t type;                     /* DM_DATA_FROM_HCI_REQ or
                                           DM_DATA_TO_HCI_IND */
    l2ca_controller_t controller;       /* AMP ID */
    uint8_t physical_handle;            /* AMP physical link handle. Not used for BR/EDR */
    uint16_t logical_handle;            /* AMP logical link handle or BR/EDR ACL handle */
    MBLK_T *data;                       /* Pointer to MBLK data. */
} DM_DATA_FROM_HCI_REQ_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */
typedef DM_DATA_FROM_HCI_REQ_T DM_DATA_TO_HCI_IND_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

/*------------------------------------------------------------------------
 *
 *      HCI API PRIMITIVES
 *
 *-----------------------------------------------------------------------*/

/******************************************************************************
 Link Control
 *****************************************************************************/

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Inquiry command
 *
 *----------------------------------------------------------------------------*/

typedef HCI_INQUIRY_T DM_HCI_INQUIRY_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Inquiry cancel command
 *
 *----------------------------------------------------------------------------*/

typedef HCI_INQUIRY_CANCEL_T DM_HCI_INQUIRY_CANCEL_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Notification of Inquiry cancel command complete
 *
 *----------------------------------------------------------------------------*/
        /* Always DM_HCI_INQUIRY_CANCEL_CFM_T */
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_INQUIRY_CANCEL_CFM_T;


/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Enter periodic inquiry mode
 *
 *----------------------------------------------------------------------------*/

typedef HCI_PERIODIC_INQUIRY_MODE_T DM_HCI_PERIODIC_INQUIRY_MODE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Notification of entered periodic inquiry mode
 *
 *----------------------------------------------------------------------------*/
        /* Always DM_HCI_PERIODIC_INQUIRY_MODE_CFM_T */
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_PERIODIC_INQUIRY_MODE_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Exit periodic inquiry mode
 *
 *----------------------------------------------------------------------------*/

typedef HCI_EXIT_PERIODIC_INQUIRY_MODE_T DM_HCI_EXIT_PERIODIC_INQUIRY_MODE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Notification of exited periodic inquiry mode
 *
 *----------------------------------------------------------------------------*/
        /* Always DM_HCI_EXIT_PERIODIC_INQUIRY_MODE_CFM_T */
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_EXIT_PERIODIC_INQUIRY_MODE_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Notification of inquiry results
 *
 *              See HCI_EV_INQUIRY_RESULT_T.
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t               type;           /* Always DM_HCI_INQUIRY_RESULT_IND_T */
    phandle_t               phandle;        /* destination phandle */
    uint8_t                 num_responses;

    HCI_INQ_RESULT_T *          result[HCI_MAX_INQ_RESULT_PTRS];

} DM_HCI_INQUIRY_RESULT_IND_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Notification of inquiry results with rssi information
 *
 *              See HCI_EV_INQUIRY_RESULT_WITH_RSSI_T.
 *----------------------------------------------------------------------------*/

#define DM_HCI_INQUIRY_RESULT_WITH_RSSI_IND ((dm_prim_t)(ENUM_DM_HCI_INQUIRY_RESULT_WITH_RSSI_IND))

typedef struct
{
    dm_prim_t               type;           /* Always DM_HCI_INQUIRY_RESULT_IND_T */
    phandle_t               phandle;        /* destination phandle */
    uint8_t                 num_responses;

    HCI_INQ_RESULT_WITH_RSSI_T *                result[HCI_MAX_INQ_RESULT_PTRS];

} DM_HCI_INQUIRY_RESULT_WITH_RSSI_IND_T;


/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Notification of inquiry complete
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_INQUIRY_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Request change of packet type on a connection.
 *
 *----------------------------------------------------------------------------*/
typedef HCI_CHANGE_CONN_PKT_TYPE_T DM_HCI_CHANGE_CONN_PKT_TYPE_REQ_T;

typedef struct
{
    dm_prim_t               type;           /* Always DM_HCI_CHANGE_ACL_CONN_PKT_TYPE_REQ */
    BD_ADDR_T               bd_addr;        /* Remote device Bluetooth address */
    hci_pkt_type_t          pkt_type;       /* Packet type to change for ACL */
} DM_HCI_CHANGE_ACL_CONN_PKT_TYPE_REQ_T;

typedef DM_HCI_BD_ADDR_COMMAND_CFM_T DM_HCI_CHANGE_ACL_CONN_PKT_TYPE_CFM_T;

typedef DM_HCI_BD_ADDR_COMMAND_CFM_T DM_HCI_CONN_PACKET_TYPE_CHANGED_IND_T;
#define DM_HCI_CONN_PACKET_TYPE_CHANGED_IND \
                            ((dm_prim_t)(ENUM_DM_HCI_CONN_PACKET_TYPE_CHANGED_IND))

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Change link key for a device
 *
 *----------------------------------------------------------------------------*/

typedef HCI_CHANGE_CONN_LINK_KEY_T DM_HCI_CHANGE_CONN_LINK_KEY_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Notification of change of link key for a device
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_BD_ADDR_COMMAND_CFM_T DM_HCI_CHANGE_CONN_LINK_KEY_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Notification of link keys for devices
 *
 *              See HCI_EV_RETURN_LINK_KEYS_T for details.
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_RETURN_LINK_KEYS_IND_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             num_keys;           /* Number of link keys */

    LINK_KEY_BD_ADDR_T  *link_key_bd_addr[HCI_STORED_LINK_KEY_MAX];

} DM_HCI_RETURN_LINK_KEYS_IND_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Use the master device link keys
 *
 *----------------------------------------------------------------------------*/

typedef HCI_MASTER_LINK_KEY_T DM_HCI_MASTER_LINK_KEY_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Notification of use of the master device link keys
 *
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_MASTER_LINK_KEY_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* Success or failure - See Note1 */
    uint8_t             key_flag;           /* Regular/Temporary link key */

} DM_HCI_MASTER_LINK_KEY_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Remote name request
 *
 *----------------------------------------------------------------------------*/

typedef HCI_REMOTE_NAME_REQ_T DM_HCI_REMOTE_NAME_REQUEST_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Notification of remote name
 *
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_REMOTE_NAME_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* Success or failure - See Note1 */
    BD_ADDR_T           bd_addr;            /* Bluetooth device address */
    /* User friendly name */
    uint8_t             *name_part[HCI_LOCAL_NAME_BYTE_PACKET_PTRS];
} DM_HCI_REMOTE_NAME_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read remote features
 *
 *----------------------------------------------------------------------------*/

typedef HCI_READ_REMOTE_SUPP_FEATURES_T DM_HCI_READ_REMOTE_SUPP_FEATURES_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Notification of remote features
 *
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_REMOTE_SUPP_FEATURES_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* Success or failure - See Note1 */
    BD_ADDR_T           bd_addr;            /* Bluetooth device address */
    uint16_t            features[4];        /* LMP features */

} DM_HCI_READ_REMOTE_SUPP_FEATURES_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read remote version
 *
 *----------------------------------------------------------------------------*/

typedef HCI_READ_REMOTE_VER_INFO_T DM_HCI_READ_REMOTE_VER_INFO_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Notification of remote version information
 *
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_REMOTE_VER_INFO_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* Success or failure - See Note1 */
    TP_BD_ADDR_T        tp_addrt;           /* Bluetooth device address */
    uint8_t             LMP_version;        /* Version of LMP */
    uint16_t            manufacturer_name;  /* Name of manufacturer */
    uint16_t            LMP_subversion;     /* Subversion of LMP */
} DM_HCI_READ_REMOTE_VER_INFO_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read clock offset
 *
 *----------------------------------------------------------------------------*/

typedef HCI_READ_CLOCK_OFFSET_T DM_HCI_READ_CLOCK_OFFSET_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read clock offset
 *
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_CLOCK_OFFSET_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* Success or failure - See Note1 */
    BD_ADDR_T           bd_addr;            /* Bluetooth device address */
    uint16_t            clock_offset;       /* Device's clock offset */

} DM_HCI_READ_CLOCK_OFFSET_CFM_T;

/******************************************************************************
   Link Policy
 *****************************************************************************/

 /*----------------------------------------------------------------------------*
 * PURPOSE
 *      Put local or remote device into hold mode
 *      Use the remote Bluetooth device address to map onto
 *      connection handle
 *
 *----------------------------------------------------------------------------*/

typedef HCI_HOLD_MODE_T DM_HCI_HOLD_MODE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Put local device (for a particular connection) into sniff mode
 *      Note, SCO connections cannot be put into sniff.
 *
 *----------------------------------------------------------------------------*/

typedef HCI_SNIFF_MODE_T DM_HCI_SNIFF_MODE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      End local device (for a particular connection) in sniff mode
 *      Note, SCO connections cannot be put into sniff.
 *
 *----------------------------------------------------------------------------*/

typedef HCI_EXIT_SNIFF_MODE_T DM_HCI_EXIT_SNIFF_MODE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Mode change event
 *
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_MODE_CHANGE_EVENT_IND_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* Success or failure - See Note1 */
    BD_ADDR_T           bd_addr;            /* Bluetooth device address */
    uint8_t             mode;               /* Current mode */
    uint16_t            length;             /* Length of mode (or similar) */

} DM_HCI_MODE_CHANGE_EVENT_IND_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Quality of service setup from L2CAP
 *
 *----------------------------------------------------------------------------*/

typedef HCI_QOS_SETUP_T DM_HCI_QOS_SETUP_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Completion of quality of service setup
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t                type;    /* always DM_HCI_QOS_SETUP_CFM */
    phandle_t                phandle; /* destination phandle */
    hci_return_t             status;  /* cast to error if error */
    BD_ADDR_T                bd_addr;            /* Bluetooth device address */
    uint8_t                  flags;              /* reserved */
    hci_qos_type_t           service_type;
    uint32_t                 token_rate;
    uint32_t                 peak_bandwidth;
    uint32_t                 latency;
    uint32_t                 delay_variation;
} DM_HCI_QOS_SETUP_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Discover role
 *      Use the bd_addr to identify the (ACL) link at this interface
 *
 *----------------------------------------------------------------------------*/

typedef HCI_ROLE_DISCOVERY_T DM_HCI_ROLE_DISCOVERY_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Discover role complete
 *
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_ROLE_DISCOVERY_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* Success or failure - See Note1 */
    BD_ADDR_T           bd_addr;            /* BD_ADDR of link */
    uint8_t             role;               /* Master or slave */
} DM_HCI_ROLE_DISCOVERY_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Switch role
 *      Use the bd_addr to identify the (ACL) link at this interface
 *
 *----------------------------------------------------------------------------*/

typedef HCI_SWITCH_ROLE_T DM_HCI_SWITCH_ROLE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Switch role complete
 *      The current role is contained in 'role', even in case of failure.
 *
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_SWITCH_ROLE_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* Success or failure - See Note1 */
    BD_ADDR_T           bd_addr;            /* BD_ADDR of link */
    uint8_t             role;               /* Master or slave */

} DM_HCI_SWITCH_ROLE_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read link policy settings from LM
 *      Use the bd_addr to identify the (ACL) link at this interface
 *
 *----------------------------------------------------------------------------*/

typedef HCI_READ_LINK_POLICY_SETTINGS_T DM_HCI_READ_LINK_POLICY_SETTINGS_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read link policy settings complete from LM
 *
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_LINK_POLICY_SETTINGS_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    BD_ADDR_T           bd_addr;            /* bd_addr of link */
    uint16_t            link_policy;        /* link policy settings */
} DM_HCI_READ_LINK_POLICY_SETTINGS_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Write link policy settings.
 *      Use the bd_addr to identify the ACL link at this interface.
 *
 *      Link Manager settings define the
 *      connection modes that are allowed (hold/sniff).
 *
 *      In all modes, the DM will keep the application informed of any changes
 *      of mode by issuing DM_HCI_MODE_CHANGE_EVENT_IND events.
 *
 *----------------------------------------------------------------------------*/

typedef HCI_WRITE_LINK_POLICY_SETTINGS_T DM_HCI_WRITE_LINK_POLICY_SETTINGS_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Defines the powerstate(s) to be applied to the specified ACL. It
 *      takes the form of a list of successive power modes which the ACL moves
 *      through over periods of increasing inactivity.  If at anytime there
 *      is activity on the ACL, control will reset to the first powerstate.
 *
 *      Each powerstate is defined using the LP_POWERSTATE_T structure.
 *      The 'mode' entry is used to define the Bluetooth power mode.
 *      The 'min_interval' etc fields define the parameters of the Bluetooth
 *          power mode - see the HCI spec.
 *      The 'duration' is the length of time, in seconds, that the ACL will
 *          remain in this state.  When this period expires, control moves
 *          to the next state.  The last powerstate therefore MUST have an
 *          infinite duration (zero).
 *
 *      Notes
 *      It is important for the application to know the remote supported 
 *      features before populating the power table. It would make no sense to 
 *      ask for low power modes those are not supported. 
 *      Refer: DM_HCI_READ_REMOTE_SUPP_FEATURES_REQ_T
 *----------------------------------------------------------------------------*/
typedef uint8_t lp_powermode_t;
#define LP_POWERMODE_ACTIVE ((lp_powermode_t)0x00)
#define LP_POWERMODE_SNIFF  ((lp_powermode_t)0x01)
/* Passive mode is a "don't care" setting where the local device will not
   attempt to alter the power mode. */
#define LP_POWERMODE_PASSIVE ((lp_powermode_t)0xff)

typedef struct
{
    lp_powermode_t mode;
    uint16_t min_interval;
    uint16_t max_interval;
    uint16_t attempt;
    uint16_t timeout;
    uint16_t duration; /* time to spend in this mode */
} LP_POWERSTATE_T;/* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef struct
{
    dm_prim_t       type;
    BD_ADDR_T       bd_addr;    /* Bluetooth Device Address */
    uint16_t        num_states; /* Number of states in list */
    LP_POWERSTATE_T *states;    /* Table of power states */
} DM_LP_WRITE_POWERSTATES_REQ_T;


/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Generated in response to DM_LP_WRITE_POWERSTATES_REQ.
 *
 *----------------------------------------------------------------------------*/
#define LP_POWERSTATES_SUCCESS          ((uint8_t)0) /* powerstates set successfully */
#define LP_POWERSTATES_UNSUPPORTED_MODE ((uint8_t)1) /* unrecognised LP_POWERMODE */
#define LP_POWERSTATES_UNKNOWN_DEVICE   ((uint8_t)2) /* unknown Bluetooth device */
#define LP_POWERSTATES_BAD_TERMINATION  ((uint8_t)3) /* last state duration not zero */
#define LP_POWERSTATES_ERROR            ((uint8_t)4) /* error described above */
typedef struct
{
    dm_prim_t   type;
    phandle_t   phandle;            /* destination phandle */
    uint8_t     result;
    BD_ADDR_T   bd_addr;
} DM_LP_WRITE_POWERSTATES_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Allows the application to modify role-switch policy for ACL
 *      connection setup.
 *
 *      The policy takes the form of a table of conditions and actions.
 *      When the device manager is about to initiate a connection to a
 *      remote device, or is about to accept an incoming connection
 *      request, it walks down the table until it reaches an entry for
 *      which all conditions are met. Role-switch policy for that ACL
 *      connection is then determined by the actions specified.
 *
 *      There are four condition criteria:
 *
 *      1) Minimum number of connections to remote slaves.
 *      2) Minimum number of connections to remote masters.
 *      3) Minimum number of connections to remote unsniffed masters.
 *      4) Minimum number of connections.
 *
 *      Each entry in the table specifies separately the minimum number of
 *      existing connections for each individual condition to be met. So the
 *      resolution operator for each condition is always >= 'greater than
 *      or equal to'.
 *
 *      There are two actions:
 *
 *      1) Accept incoming connection with role-switch (becoming master).
 *      2) Request outgoing connection, prohibiting role-switch (staying master).
 *
 *      Either, both, or neither action can be set for any specified
 *      combination of conditions. If an action isn't specified, then the
 *      reverse happens, i.e. outgoing connections are requested allowing
 *      role-switch and incoming connections are accepted without requesting
 *      role-switch.
 *
 *      Encoding
 *      Each 'row' in the table is encoded into a single uint16.
 *      Each condition is encoded into 3 bits, giving a range of 0-7.
 *      Each action is encoded into 1 bit - setting the bit turns on the action.
 *
 *      Bits
 *        0-2  Condition - minimum number of remote slaves.
 *        3-5  Condition - minimum number of remote masters.
 *        6-8  Condition - minimum number of remote unsniffed masters.
 *        9-11 Condition - minimum number of connections.
 *       12    Action - Accept incoming connection with role-switch.
 *       13    Action - Request outgoing connection, prohibiting role-switch.
 *       15-16 Reserved - must be set to zero.
 *
 *       There are macros defined below to make packing the conditions easier.
 *
 *      Restrictions
 *      1) The final table entry must be 0 - i.e. 'always do nothing'.
 *      2) The reserved bits must all be set to 0.
 *      3) All table entries (except the last) must have at least one
 *         non-zero condition.
 *
 *      Operation
 *      Subsequent valid tables sent will replace any existing table.
 *      Sending a zero-length table will delete any existing table.
 *      If the device manager does not have a table then it will default
 *      to its legacy behaviour, which was to never prohibit role-switch
 *      when requesting connection creation and only to request a role-switch
 *      when accepting remote connection requests if there is already an
 *      existing connection to some other device.
 *
 *      Notes
 *      The purpose of this feature is to help manage and hopefully simplify
 *      scatternet topology. Using it for any other purpose is likely to
 *      severely reduce device interoperability. In particular, prohibiting
 *      role-switch on outgoing connections should be used sparingly, as it
 *      may be that the topology that the remote device finds itself in is
 *      even more complicated than that for the local device and the only way
 *      for the connection to succeed is with a role-switch.
 *
 *--------------------------------------------------------------------------*/

/* Bits reserved per condition */
#define DM_LP_ROLESWITCH_CONDITION_BITS                     3

/* Conditions */
#define DM_ACL_NUM_SLAVES                                   0
#define DM_ACL_NUM_MASTERS                                  1
#define DM_ACL_NUM_UNSNIFFED_MASTERS                        2
#define DM_ACL_NUM_CONNECTIONS                              3
#define DM_ACL_NUM_END                                      4

/* Actions */
#define DM_LP_ROLESWITCH_ACTION_INCOMING_RS                 0x1000
#define DM_LP_ROLESWITCH_ACTION_OUTGOING_NO_RS              0x2000

 /* Reserved (must not be set) */
#define DM_LP_ROLESWITCH_RESERVED_1                         0x4000
#define DM_LP_ROLESWITCH_RESERVED_2                         0x8000

/* Macro to encode conditions */
#define DM_LP_ROLESWITCH_WRITE_CONDITION(value, condition)  \
    ((value) << ((condition) * DM_LP_ROLESWITCH_CONDITION_BITS))

/* Macro to decode conditions */
#define DM_LP_ROLESWITCH_READ_CONDITION(policy, condition)  \
    (((policy) >> ((condition) * DM_LP_ROLESWITCH_CONDITION_BITS)) & 7)


/* Macro to encode complete table entry
 *
 * slv, mst, usm, con are the four conditions - enter a number 0-7 for each
 * rs_in - enter 0 or DM_LP_ROLESWITCH_ACTION_INCOMING_RS
 * no_rs_out - enter 0 or DM_LP_ROLESWITCH_ACTION_OUTGOING_NO_RS
 */
#define DM_LP_ROLESWITCH_TABLE_ENTRY(slv, mst, usm, con, rs_in, no_rs_out) \
     (DM_LP_ROLESWITCH_WRITE_CONDITION((slv), DM_ACL_NUM_SLAVES) \
    | DM_LP_ROLESWITCH_WRITE_CONDITION((mst), DM_ACL_NUM_MASTERS) \
    | DM_LP_ROLESWITCH_WRITE_CONDITION((usm), DM_ACL_NUM_UNSNIFFED_MASTERS) \
    | DM_LP_ROLESWITCH_WRITE_CONDITION((con), DM_ACL_NUM_CONNECTIONS) \
    | rs_in \
    | no_rs_out)

/* Masks */
#define DM_LP_ROLESWITCH_CONDITION_MASK                     0x0FFF
#define DM_LP_ROLESWITCH_ACTION_MASK                        0x3000
#define DM_LP_ROLESWITCH_RESERVED_MASK                      0xC000

typedef struct
{
    dm_prim_t           type;               /* Always DM_LP_WRITE_ROLESWITCH_POLICY_REQ */
    uint16_t            version;            /* Must be set to 0 */
    uint16_t            length;             /* Number of uint16s in table */
    uint16_t            *rs_table;          /* Pointer to role-switch table */
} DM_LP_WRITE_ROLESWITCH_POLICY_REQ_T;

/*---------------------------------------------------------------------------*
 * PURPOSE
 *      Response to DM_LP_WRITE_ROLESWITCH_POLICY_REQ.
 *
 *---------------------------------------------------------------------------*/


#define DM_LP_WRITE_ROLESWITCH_POLICY_SUCCESS               ((uint8_t)0)
#define DM_LP_WRITE_ROLESWITCH_POLICY_ILLEGAL               ((uint8_t)1)
#define DM_LP_WRITE_ROLESWITCH_POLICY_UNSUPPORTED           ((uint8_t)2)
#define DM_LP_WRITE_ROLESWITCH_POLICY_NOT_ZERO_TERMINATED   ((uint8_t)3)
typedef struct
{
    dm_prim_t           type;               /* Always DM_LP_WRITE_ROLESWITCH_POLICY_CFM */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* Indication of success or failure */
} DM_LP_WRITE_ROLESWITCH_POLICY_CFM_T;

/*---------------------------------------------------------------------------*
 * PURPOSE
 *      Maintain list of remote devices for which the Device Manager will
 *      always try to become master during any ACL connection creation,
 *      even if there are no existing ACLs connected.
 *
 *      For locally-initiated connection requests to devices in the list,
 *      the Device Manager will prohibit role-switch, thus ensuring that
 *      the local device becomes master.
 *
 *      For remotely-initiated connection requests to devices in the list,
 *      the Device Manager will request a role-switch during connection
 *      creation. This may or may not be accepted by the remote device.
 *
 *      This primitive may be used to:
 *
 *      1) ADD a new device to the list
 *      2) DELETE a device from the list
 *      3) CLEAR the entire list
 *
 *      This primitive should be used only to work around problems with
 *      severely misbehaving remote devices. Any other use is likely to
 *      produce a severely misbehaving local device and lead to major
 *      interoperability problems.
 *
 *      Role-switches should only be used to simplify topology. In most
 *      cases, DM_LP_WRITE_ROLESWITCH_POLICY_REQ/CFM should be sufficient.
 *      DM_LP_WRITE_ALWAYS_MASTER_DEVICES_REQ/CFM should only be used
 *      when it is necessary to become master, even when there are no
 *      existing connections, because the remote device is badly behaved
 *      and will not role-switch after connection creation and it is likely
 *      that further ACLs will soon be connected. (If it turns out that
 *      no further ACLs materialise after a connection affected by the
 *      device list is created then the local device might want to
 *      consider initiating a role-switch to become slave.)
 *---------------------------------------------------------------------------*/
#define DM_LP_WRITE_ALWAYS_MASTER_DEVICES_CLEAR     0x0000
#define DM_LP_WRITE_ALWAYS_MASTER_DEVICES_ADD       0x0001
#define DM_LP_WRITE_ALWAYS_MASTER_DEVICES_DELETE    0x0002
typedef struct
{
    dm_prim_t           type;           /* Always DM_LP_WRITE_ALWAYS_MASTER_DEVICES_REQ */
    uint16_t            operation;      /* ADD, DELETE, CLEAR. */
    BD_ADDR_T           bd_addr;        /* Pointer to array of Bluetooth addresses. */
} DM_LP_WRITE_ALWAYS_MASTER_DEVICES_REQ_T;

#define DM_LP_WRITE_ALWAYS_MASTER_DEVICES_SUCCESS   0x00
#define DM_LP_WRITE_ALWAYS_MASTER_DEVICES_ILLEGAL   0x01
typedef struct
{
    dm_prim_t           type;           /* Always DM_LP_WRITE_ALWAYS_MASTER_DEVICES_CFM */
    phandle_t           phandle;        /* destination phandle */
    uint8_t             status;         /* Indication of success or failure */
} DM_LP_WRITE_ALWAYS_MASTER_DEVICES_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Write link policy settings complete from LM
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_BD_ADDR_COMMAND_CFM_T DM_HCI_WRITE_LINK_POLICY_SETTINGS_CFM_T;

/*---------------------------------------------------------------------------*
 * PURPOSE
 *      FSM Debugging primitives. Provides details of Bluestack state
 *      machine transitions.
 *      Will not be compiled into production firmware.
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;
    phandle_t       phandle;
    uint16_t        state_machine;
    uint32_t        event;
    uint32_t        old_state;
    uint32_t        new_state;
    uint32_t        action;
} DM_BLUESTACK_STATE_TRANSITION_ENTRY_IND_T;

typedef struct
{
    dm_prim_t       type;
    phandle_t       phandle;
    uint16_t        state_machine;
    uint32_t        event;
} DM_BLUESTACK_STATE_TRANSITION_EXIT_IND_T;

/******************************************************************************
   Host Controller and Baseband
 *****************************************************************************/
/*
 * These primitives will map directly onto HCI primitives
 *
 */
typedef HCI_SET_EVENT_MASK_T DM_HCI_SET_EVENT_MASK_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Notification of set event mask
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_SET_EVENT_MASK_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Request for HCI reset.
 *
 *      Note: If CSB stream is in used, LC will destroy CSB stream once HCI
 *      reset command is received. It is caller responsibility to clean up
 *      resources (source/sink stream etc.) and send DM_HCI_RESET accordingly.
 *
 *----------------------------------------------------------------------------*/
typedef HCI_RESET_T DM_HCI_RESET_REQ_T;
/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Notification of reset command
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_RESET_CFM_T;

typedef HCI_SET_EVENT_FILTER_T DM_HCI_SET_EVENT_FILTER_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Request for flush
 *
 *----------------------------------------------------------------------------*/
typedef HCI_FLUSH_T DM_HCI_FLUSH_REQ_T;

        /* Always DM_HCI_SET_EVENT_FILTER_CFM_T */
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_SET_EVENT_FILTER_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Notification of flush complete
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_BD_ADDR_COMMAND_CFM_T DM_HCI_FLUSH_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Notification of set event filter command
 *
 *----------------------------------------------------------------------------*/

typedef HCI_READ_PIN_TYPE_T DM_HCI_READ_PIN_TYPE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read pin type complete event
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_PIN_TYPE_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    pin_type_t          pin_type;           /* the pin type */

} DM_HCI_READ_PIN_TYPE_CFM_T;

typedef HCI_WRITE_PIN_TYPE_T DM_HCI_WRITE_PIN_TYPE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Write pin type complete event
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_PIN_TYPE_CFM_T;

typedef HCI_READ_STORED_LINK_KEY_T DM_HCI_READ_STORED_LINK_KEY_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read stored link key complete event
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_STORED_LINK_KEY_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint16_t            max_num_keys;
    uint16_t            num_keys_read;
} DM_HCI_READ_STORED_LINK_KEY_CFM_T;

typedef HCI_WRITE_STORED_LINK_KEY_T DM_HCI_WRITE_STORED_LINK_KEY_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Write stored link key complete event
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_WRITE_STORED_LINK_KEY_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint8_t             num_keys_written;
} DM_HCI_WRITE_STORED_LINK_KEY_CFM_T;

typedef HCI_DELETE_STORED_LINK_KEY_T DM_HCI_DELETE_STORED_LINK_KEY_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Delete stored link keys complete event
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_DELETE_STORED_LINK_KEY_CFM */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint16_t            num_keys_deleted;
} DM_HCI_DELETE_STORED_LINK_KEY_CFM_T;

typedef HCI_CHANGE_LOCAL_NAME_T DM_HCI_CHANGE_LOCAL_NAME_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Change local name complete event
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_CHANGE_LOCAL_NAME_CFM_T;

typedef HCI_READ_CONN_ACCEPT_TIMEOUT_T DM_HCI_READ_CONN_ACCEPT_TIMEOUT_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      read local name
 *
 *----------------------------------------------------------------------------*/
typedef HCI_READ_LOCAL_NAME_T DM_HCI_READ_LOCAL_NAME_REQ_T;

typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_LOCAL_NAME_CFM */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    /* See HCI_READ_LOCAL_NAME_RET_T */
    uint8_t            *name_part[HCI_LOCAL_NAME_BYTE_PACKET_PTRS];
} DM_HCI_READ_LOCAL_NAME_CFM_T;

typedef HCI_WRITE_CONN_ACCEPT_TIMEOUT_T DM_HCI_WRITE_CONN_ACCEPT_TIMEOUT_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read connection accept timeout complete event
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_CONN_ACCEPT_TIMEOUT_CFM */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint16_t            conn_accept_timeout;/* the timeout value */
} DM_HCI_READ_CONN_ACCEPT_TIMEOUT_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Write connection accept timeout complete event
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_CONN_ACCEPT_TIMEOUT_CFM_T;

typedef HCI_READ_PAGE_TIMEOUT_T DM_HCI_READ_PAGE_TIMEOUT_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read page timeout complete event
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_PAGE_TIMEOUT_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint16_t            page_timeout;       /* the timeout value */
} DM_HCI_READ_PAGE_TIMEOUT_CFM_T;

typedef HCI_WRITE_PAGE_TIMEOUT_T DM_HCI_WRITE_PAGE_TIMEOUT_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Write page timeout complete event
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_PAGE_TIMEOUT_CFM_T;

typedef HCI_READ_SCAN_ENABLE_T DM_HCI_READ_SCAN_ENABLE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read scan enable complete event
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_SCAN_ENABLE_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint8_t             scan_enable;        /* return parameter */
} DM_HCI_READ_SCAN_ENABLE_CFM_T;

typedef HCI_WRITE_SCAN_ENABLE_T DM_HCI_WRITE_SCAN_ENABLE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Write scan enable complete event
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_SCAN_ENABLE_CFM_T;

typedef HCI_READ_PAGESCAN_ACTIVITY_T DM_HCI_READ_PAGESCAN_ACTIVITY_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read pagescan activity complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_PAGESCAN_ACTIVITY_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint16_t            pagescan_interval;
    uint16_t            pagescan_window;
} DM_HCI_READ_PAGESCAN_ACTIVITY_CFM_T;

typedef HCI_WRITE_PAGESCAN_ACTIVITY_T DM_HCI_WRITE_PAGESCAN_ACTIVITY_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Write pagescan activity complete
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_PAGESCAN_ACTIVITY_CFM_T;

typedef HCI_READ_INQUIRYSCAN_ACTIVITY_T DM_HCI_READ_INQUIRYSCAN_ACTIVITY_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read inquiryscan activity complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_INQUIRYSCAN_ACTIVITY_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint16_t            inqscan_interval;
    uint16_t            inqscan_window;
} DM_HCI_READ_INQUIRYSCAN_ACTIVITY_CFM_T;

typedef HCI_WRITE_INQUIRYSCAN_ACTIVITY_T DM_HCI_WRITE_INQUIRYSCAN_ACTIVITY_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Write inquiryscan activity complete
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_INQUIRYSCAN_ACTIVITY_CFM_T;

typedef HCI_READ_AUTH_ENABLE_T DM_HCI_READ_AUTH_ENABLE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read authentication enable complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_AUTH_ENABLE_CFM */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint8_t             auth_enable;
} DM_HCI_READ_AUTH_ENABLE_CFM_T;

typedef HCI_READ_ENC_MODE_T DM_HCI_READ_ENC_MODE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read encryption mode complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_ENC_MODE_CFM */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint8_t             mode;
} DM_HCI_READ_ENC_MODE_CFM_T;

typedef HCI_READ_CLASS_OF_DEVICE_T DM_HCI_READ_CLASS_OF_DEVICE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read class of device complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_CLASS_OF_DEVICE_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint32_t            dev_class;
} DM_HCI_READ_CLASS_OF_DEVICE_CFM_T;

typedef HCI_WRITE_CLASS_OF_DEVICE_T DM_HCI_WRITE_CLASS_OF_DEVICE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Write class of device complete
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_CLASS_OF_DEVICE_CFM_T;

typedef HCI_READ_VOICE_SETTING_T DM_HCI_READ_VOICE_SETTING_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read voice setting complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_VOICE_SETTING_CFM */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint16_t            voice_setting;
} DM_HCI_READ_VOICE_SETTING_CFM_T;

typedef HCI_WRITE_VOICE_SETTING_T DM_HCI_WRITE_VOICE_SETTING_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Write voice setting complete
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_VOICE_SETTING_CFM_T;

typedef HCI_READ_NUM_BCAST_RETXS_T DM_HCI_READ_NUM_BCAST_RETXS_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Request for Reading the automatic flush timeout
 *
 *----------------------------------------------------------------------------*/
typedef HCI_READ_AUTO_FLUSH_TIMEOUT_T DM_HCI_READ_AUTO_FLUSH_TIMEOUT_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read Auto Flush Timeout complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_AUTO_FLUSH_CFM */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    BD_ADDR_T           bd_addr;            /* bd_addr of link (Always ACL)*/
    uint16_t            FlushTimeout;       /* 11 bits of this number * 0.625ms */
} DM_HCI_READ_AUTO_FLUSH_TIMEOUT_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Request for Writing the automatic flush timeout
 *
 *      Note: Bluestack internally configures automatic flush timeout value for
 *      the ACL by analyzing individual L2CAP channel's flush timeout
 *      requirements.  Currently it is configured to be at least minimum of all
 *      active L2CAP channel's flush timeout. It is advised that this command
 *      shall not be used unless API user is aware of flush timeout requirements
 *      of all L2CAP channels and intends to override Bluestack's internal logic
 *      for configuring flush timeout.
 *----------------------------------------------------------------------------*/
typedef HCI_WRITE_AUTO_FLUSH_TIMEOUT_T DM_HCI_WRITE_AUTO_FLUSH_TIMEOUT_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Write Auto Flush Timeout complete
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_BD_ADDR_COMMAND_CFM_T DM_HCI_WRITE_AUTO_FLUSH_TIMEOUT_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Request for Reading SCO Flow Control Settings
 *
 *----------------------------------------------------------------------------*/
typedef HCI_READ_SCO_FLOW_CON_ENABLE_T DM_HCI_READ_SCO_FLOW_CON_ENABLE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Write Auto Flush Timeout complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint8_t             FlowControlEnabled;
} DM_HCI_READ_SCO_FLOW_CON_ENABLE_CFM_T;/* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Request for Writing SCO Flow Control Settings
 *
 *----------------------------------------------------------------------------*/
typedef HCI_WRITE_SCO_FLOW_CON_ENABLE_T DM_HCI_WRITE_SCO_FLOW_CON_ENABLE_REQ_T;/* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Write SCO Flow Control complete
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_SCO_FLOW_CON_ENABLE_CFM_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read number of broadcast transmissions complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_NUM_BCAST_RETXS_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint8_t             num;
} DM_HCI_READ_NUM_BCAST_RETXS_CFM_T;

typedef HCI_WRITE_NUM_BCAST_RETXS_T DM_HCI_WRITE_NUM_BCAST_RETXS_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Write number of broadcast transmissions complete
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_NUM_BCAST_RETXS_CFM_T;

typedef HCI_READ_HOLD_MODE_ACTIVITY_T DM_HCI_READ_HOLD_MODE_ACTIVITY_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Write number of broadcast transmissions complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_HOLD_MODE_ACTIVITY_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint8_t             activity;
} DM_HCI_READ_HOLD_MODE_ACTIVITY_CFM_T;

typedef HCI_WRITE_HOLD_MODE_ACTIVITY_T DM_HCI_WRITE_HOLD_MODE_ACTIVITY_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Write hold mode activity complete
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_HOLD_MODE_ACTIVITY_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read transmit power level - use the bd_addr to reference the link
 *
 *----------------------------------------------------------------------------*/
typedef HCI_READ_TX_POWER_LEVEL_T DM_HCI_READ_TX_POWER_LEVEL_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read transmit power level complete - use the bd_addr to reference the link
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t            type;               /* Always DM_HCI_READ_TX_POWER_LEVEL_CFM_T */
    phandle_t            phandle;            /* destination phandle */
    uint8_t              status;             /* status */
    TP_BD_ADDR_T         tp_addrt;           /* bd_addr of the link */
    int8_t               pwr_level;
} DM_HCI_READ_TX_POWER_LEVEL_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Indicate to the Controller the number of HCI Data packets that have
 *      been completed for each connection handle since the previous 
 *      HCI_Host_Number_Of_Completed_Packets command was sent to the Controller.
 *
 *----------------------------------------------------------------------------*/
typedef HCI_HOST_NUM_COMPLETED_PACKETS_T DM_HCI_HOST_NUM_COMPLETED_PACKETS_REQ_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      read link supervision timeout
 *
 *----------------------------------------------------------------------------*/
typedef HCI_READ_LINK_SUPERV_TIMEOUT_T DM_HCI_READ_LINK_SUPERV_TIMEOUT_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      read link supervision timeout complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_LINK_SUPERV_TIMEOUT_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    BD_ADDR_T           bd_addr;
    uint16_t            timeout;
} DM_HCI_READ_LINK_SUPERV_TIMEOUT_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Write link supervision timeout
 *
 *----------------------------------------------------------------------------*/
typedef HCI_WRITE_LINK_SUPERV_TIMEOUT_T DM_HCI_WRITE_LINK_SUPERV_TIMEOUT_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      write link supervision timeout complete
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_BD_ADDR_COMMAND_CFM_T DM_HCI_WRITE_LINK_SUPERV_TIMEOUT_CFM_T;

typedef HCI_READ_NUM_SUPPORTED_IAC_T DM_HCI_READ_NUM_SUPPORTED_IAC_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      read num support iac complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_NUM_SUPPORTED_IAC_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint8_t             num;
} DM_HCI_READ_NUM_SUPPORTED_IAC_CFM_T;

typedef HCI_READ_CURRENT_IAC_LAP_T DM_HCI_READ_CURRENT_IAC_LAP_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      read current iac lap complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_CURRENT_IAC_LAP_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint8_t             num_current_iac;

    /* Array of HCI_IAC_LAP_PTRS pointers to HCI_IAC_LAP_PER_PTR iac */
    uint24_t *          iac_lap[HCI_IAC_LAP_PTRS];
} DM_HCI_READ_CURRENT_IAC_LAP_CFM_T;

typedef HCI_WRITE_CURRENT_IAC_LAP_T DM_HCI_WRITE_CURRENT_IAC_LAP_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      write current iac lap complete
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_CURRENT_IAC_LAP_CFM_T;

typedef HCI_READ_PAGESCAN_PERIOD_MODE_T DM_HCI_READ_PAGESCAN_PERIOD_MODE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      read pagescan period mode complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_PAGESCAN_PERIOD_MODE_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint8_t             mode;
} DM_HCI_READ_PAGESCAN_PERIOD_MODE_CFM_T;

typedef HCI_WRITE_PAGESCAN_PERIOD_MODE_T DM_HCI_WRITE_PAGESCAN_PERIOD_MODE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      write pagescan period mode complete
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_PAGESCAN_PERIOD_MODE_CFM_T;

typedef HCI_READ_PAGESCAN_MODE_T DM_HCI_READ_PAGESCAN_MODE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      read pagescan mode complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_PAGESCAN_MODE_CFM_T */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint8_t             mode;
} DM_HCI_READ_PAGESCAN_MODE_CFM_T;

typedef HCI_WRITE_PAGESCAN_MODE_T DM_HCI_WRITE_PAGESCAN_MODE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      write pagescan mode complete
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_PAGESCAN_MODE_CFM_T;

/******************************************************************************
   Informational parameters
 *****************************************************************************/

typedef HCI_READ_LOCAL_VER_INFO_T DM_HCI_READ_LOCAL_VER_INFO_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read local version complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_LOCAL_VER_INFO_CFM */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    hci_version_t       hci_version;
    uint16_t            hci_revision;
    uint8_t             lmp_version;        /* defined in LMP */
    uint16_t            manuf_name;         /* defined in LMP */
    uint16_t            lmp_subversion;
} DM_HCI_READ_LOCAL_VER_INFO_CFM_T;

typedef HCI_READ_LOCAL_SUPP_FEATURES_T DM_HCI_READ_LOCAL_SUPP_FEATURES_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read local features complete
 *      The bit mask remains be as per the specification.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_LOCAL_SUPP_FEATURES_CFM */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint8_t             lmp_supp_features[8];
} DM_HCI_READ_LOCAL_SUPP_FEATURES_CFM_T;

typedef HCI_READ_COUNTRY_CODE_T DM_HCI_READ_COUNTRY_CODE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Read country code complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Always DM_HCI_READ_COUNTRY_CODE_CFM */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* status */
    uint8_t             country_code;
} DM_HCI_READ_COUNTRY_CODE_CFM_T;

typedef HCI_READ_BD_ADDR_T DM_HCI_READ_BD_ADDR_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      read bd_addr return primitive
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_BD_ADDR_COMMAND_CFM_T DM_HCI_READ_BD_ADDR_CFM_T;

/******************************************************************************
   Status parameters
 *****************************************************************************/

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      read failed contact counter
 *
 *----------------------------------------------------------------------------*/
typedef HCI_READ_FAILED_CONTACT_COUNT_T DM_HCI_READ_FAILED_CONTACT_COUNT_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      read failed contact counter complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;    /* always DM_HCI_READ_FAILED_CONTACT_COUNT_CFM */
    phandle_t               phandle; /* destination phandle */
    uint8_t                 status;         /* Success or failure - See Note1 */
    BD_ADDR_T               bd_addr;
    uint16_t                failed_contact_count;
} DM_HCI_READ_FAILED_CONTACT_COUNT_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      reset contact counter request
 *
 *----------------------------------------------------------------------------*/
typedef HCI_RESET_FAILED_CONTACT_COUNT_T DM_HCI_RESET_FAILED_CONTACT_COUNT_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      reset contact counter complete
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_BD_ADDR_COMMAND_CFM_T DM_HCI_RESET_FAILED_CONTACT_COUNT_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      get link quality
 *
 *----------------------------------------------------------------------------*/
typedef HCI_GET_LINK_QUALITY_T DM_HCI_GET_LINK_QUALITY_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      get link quality complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;    /* always DM_HCI_GET_LINK_QUALITY_CFM */
    phandle_t               phandle; /* destination phandle */
    uint8_t                 status;         /* Success or failure - See Note1 */
    BD_ADDR_T               bd_addr;
    uint8_t                 link_quality;
} DM_HCI_GET_LINK_QUALITY_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      read RSSI
 *
 *----------------------------------------------------------------------------*/
typedef HCI_READ_RSSI_T DM_HCI_READ_RSSI_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      read RSSI complete
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;    /* always DM_HCI_READ_RSSI_CFM */
    phandle_t               phandle; /* destination phandle */
    uint8_t                 status;         /* Success or failure - See Note1 */
    TP_BD_ADDR_T            tp_addrt;
    int8_t                  rssi;
} DM_HCI_READ_RSSI_CFM_T;

/******************************************************************************
   Testing primitives
 *****************************************************************************/
/*
 * These primitives will map directly onto HCI primitives
 *
 */

typedef HCI_ENABLE_DUT_MODE_T DM_HCI_ENABLE_DUT_MODE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Enable device under test complete
 *
 *----------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ENABLE_DUT_MODE_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Common elements of an "upstream" primitive
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;
    phandle_t               phandle;
} DM_UPSTREAM_COMMON_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef struct
{
    dm_prim_t               type;
    phandle_t               phandle;
    BD_ADDR_T               bd_addr;
} DM_UPSTREAM_BD_ADDR_COMMON_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef struct
{
    dm_prim_t               type;
    phandle_t               phandle;
    TYPED_BD_ADDR_T         addrt;
} DM_UPSTREAM_TYPED_BD_ADDR_COMMON_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef HCI_CREATE_CONNECTION_CANCEL_T DM_HCI_CREATE_CONNECTION_CANCEL_REQ_T;
#define DM_HCI_CREATE_CONNECTION_CANCEL_REQ ((dm_prim_t)(ENUM_DM_HCI_CREATE_CONNECTION_CANCEL_REQ))
#define DM_HCI_CREATE_CONNECTION_CANCEL_CFM ((dm_prim_t)(ENUM_DM_HCI_CREATE_CONNECTION_CANCEL_CFM))

typedef DM_HCI_BD_ADDR_COMMAND_CFM_T DM_HCI_CREATE_CONNECTION_CANCEL_CFM_T;

typedef HCI_REMOTE_NAME_REQ_CANCEL_T DM_HCI_REMOTE_NAME_REQ_CANCEL_REQ_T;
#define DM_HCI_REMOTE_NAME_REQ_CANCEL_REQ ((dm_prim_t)(ENUM_DM_HCI_REMOTE_NAME_REQ_CANCEL_REQ))
#define DM_HCI_REMOTE_NAME_REQ_CANCEL_CFM ((dm_prim_t)(ENUM_DM_HCI_REMOTE_NAME_REQ_CANCEL_CFM))

typedef DM_HCI_BD_ADDR_COMMAND_CFM_T DM_HCI_REMOTE_NAME_REQ_CANCEL_CFM_T;

typedef HCI_READ_REMOTE_EXT_FEATURES_T DM_HCI_READ_REMOTE_EXT_FEATURES_REQ_T;
#define DM_HCI_READ_REMOTE_EXT_FEATURES_REQ ((dm_prim_t)(ENUM_DM_HCI_READ_REMOTE_EXT_FEATURES_REQ))
#define DM_HCI_READ_REMOTE_EXT_FEATURES_CFM ((dm_prim_t)(ENUM_DM_HCI_READ_REMOTE_EXT_FEATURES_CFM))

typedef struct
{
     dm_prim_t               type;           /* DM_HCI_READ_REMOTE_EXT_FEATURES_CFM_T */
     phandle_t               phandle;        /* destination phandle */
     uint8_t                 status;         /* Success or failure - See Note1 */
     BD_ADDR_T               bd_addr ;
     uint8_t                 page_num;
     uint8_t                 max_page_num;
     uint16_t                lmp_ext_features[4];
} DM_HCI_READ_REMOTE_EXT_FEATURES_CFM_T;


typedef HCI_READ_LMP_HANDLE_T DM_HCI_READ_LMP_HANDLE_REQ_T;
#define DM_HCI_READ_LMP_HANDLE_REQ ((dm_prim_t)(ENUM_DM_HCI_READ_LMP_HANDLE_REQ))
#define DM_HCI_READ_LMP_HANDLE_CFM ((dm_prim_t)(ENUM_DM_HCI_READ_LMP_HANDLE_CFM))

typedef struct
{
    dm_prim_t               type;           /* DM_HCI_READ_LMP_HANDLE_CFM_T */
    phandle_t               phandle;        /* destination phandle */
    uint8_t                 status;         /* Success or failure - See Note1 */
    hci_connection_handle_t handle;
    uint8_t                 lmp_handle;
    uint32_t                reserved;
} DM_HCI_READ_LMP_HANDLE_CFM_T;


typedef HCI_READ_DEFAULT_LINK_POLICY_SETTINGS_T DM_HCI_READ_DEFAULT_LINK_POLICY_SETTINGS_REQ_T;
#define DM_HCI_READ_DEFAULT_LINK_POLICY_SETTINGS_REQ ((dm_prim_t)(ENUM_DM_HCI_READ_DEFAULT_LINK_POLICY_SETTINGS_REQ))
#define DM_HCI_READ_DEFAULT_LINK_POLICY_SETTINGS_CFM ((dm_prim_t)(ENUM_DM_HCI_READ_DEFAULT_LINK_POLICY_SETTINGS_CFM))

typedef struct
{
    dm_prim_t               type;           /* DM_HCI_READ_DEFAULT_LINK_POLICY_SETTINGS_CFM_T */
    phandle_t               phandle;        /* destination phandle */
    uint8_t                 status;         /* Success or failure - See Note1 */
    link_policy_settings_t  default_lps;
} DM_HCI_READ_DEFAULT_LINK_POLICY_SETTINGS_CFM_T;


typedef HCI_WRITE_DEFAULT_LINK_POLICY_SETTINGS_T DM_HCI_WRITE_DEFAULT_LINK_POLICY_SETTINGS_REQ_T;
#define DM_HCI_WRITE_DEFAULT_LINK_POLICY_SETTINGS_REQ ((dm_prim_t)(ENUM_DM_HCI_WRITE_DEFAULT_LINK_POLICY_SETTINGS_REQ))
#define DM_HCI_WRITE_DEFAULT_LINK_POLICY_SETTINGS_CFM ((dm_prim_t)(ENUM_DM_HCI_WRITE_DEFAULT_LINK_POLICY_SETTINGS_CFM))

typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_DEFAULT_LINK_POLICY_SETTINGS_CFM_T;

typedef HCI_FLOW_SPEC_T DM_HCI_FLOW_SPEC_REQ_T;
#define DM_HCI_FLOW_SPEC_REQ ((dm_prim_t)(ENUM_DM_HCI_FLOW_SPEC_REQ))
#define DM_HCI_FLOW_SPEC_CFM ((dm_prim_t)(ENUM_DM_HCI_FLOW_SPEC_CFM))

typedef struct
{
    dm_prim_t               type;           /* DM_HCI_FLOW_SPEC_CFM_T */
    phandle_t               phandle;        /* destination phandle */
    uint8_t                 status;         /* Success or failure - See Note1 */
    BD_ADDR_T              bd_addr ;
    uint8_t                 flags;
    uint8_t                 flow_direction; /* 0=out (to air), 1=in (from air) */
    uint8_t                 service_type;
    uint32_t                token_rate;
    uint32_t                token_bucket_size;
    uint32_t                peak_bandwidth;
    uint32_t                access_latency;
} DM_HCI_FLOW_SPEC_CFM_T;

typedef struct
{
    dm_prim_t               type;           /* DM_HCI_SNIFF_SUB_RATING_IND */
    phandle_t               phandle;        /* destination phandle */
    uint8_t                 status;
    BD_ADDR_T               bd_addr;
    uint16_t                transmit_latency;
    uint16_t                receive_latency;
    uint16_t                remote_timeout;
    uint16_t                local_timeout;
} DM_HCI_SNIFF_SUB_RATING_IND_T;
typedef HCI_SNIFF_SUB_RATE_T DM_HCI_SNIFF_SUB_RATE_REQ_T;
#define DM_HCI_SNIFF_SUB_RATE_REQ ((dm_prim_t)(ENUM_DM_HCI_SNIFF_SUB_RATE_REQ))
#define DM_HCI_SNIFF_SUB_RATE_CFM \
                            ((dm_prim_t)(ENUM_DM_HCI_SNIFF_SUB_RATE_CFM))
#define DM_HCI_SNIFF_SUB_RATING_IND \
                            ((dm_prim_t)(ENUM_DM_HCI_SNIFF_SUB_RATING_IND))

typedef DM_HCI_BD_ADDR_COMMAND_CFM_T DM_HCI_SNIFF_SUB_RATE_CFM_T;

typedef HCI_READ_EXTENDED_INQUIRY_RESPONSE_DATA_T DM_HCI_READ_EXTENDED_INQUIRY_RESPONSE_DATA_REQ_T;
#define DM_HCI_READ_EXTENDED_INQUIRY_RESPONSE_DATA_REQ \
                ((dm_prim_t)(ENUM_DM_HCI_READ_EXTENDED_INQUIRY_RESPONSE_DATA_REQ))
typedef HCI_WRITE_EXTENDED_INQUIRY_RESPONSE_DATA_T DM_HCI_WRITE_EXTENDED_INQUIRY_RESPONSE_DATA_REQ_T;
#define DM_HCI_WRITE_EXTENDED_INQUIRY_RESPONSE_DATA_REQ \
                ((dm_prim_t)(ENUM_DM_HCI_WRITE_EXTENDED_INQUIRY_RESPONSE_DATA_REQ))

typedef struct
{
    /* DM_HCI_READ_EXTENDED_INQUIRY_RESPONSE_DATA_CFM */
    dm_prim_t               type;
    uint16_t                phandle;
    uint8_t                 status;
    uint8_t                 fec_required;
    uint8_t                 *eir_data_part[HCI_EIR_DATA_PACKET_PTRS];
} DM_HCI_READ_EXTENDED_INQUIRY_RESPONSE_DATA_CFM_T;

#define DM_HCI_READ_EXTENDED_INQUIRY_RESPONSE_DATA_CFM \
    ((dm_prim_t)(ENUM_DM_HCI_READ_EXTENDED_INQUIRY_RESPONSE_DATA_CFM))

typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_EXTENDED_INQUIRY_RESPONSE_DATA_CFM_T;

#define DM_HCI_WRITE_EXTENDED_INQUIRY_RESPONSE_DATA_CFM \
    ((dm_prim_t)(ENUM_DM_HCI_WRITE_EXTENDED_INQUIRY_RESPONSE_DATA_CFM))

typedef struct
{
    dm_prim_t               type;   /* DM_HCI_EXTENDED_INQUIRY_RESULT_IND */
    uint16_t                phandle;
    uint8_t                 num_responses;
    HCI_INQ_RESULT_WITH_RSSI_T  result;
    uint8_t                 *eir_data_part[HCI_EIR_DATA_PACKET_PTRS];
} DM_HCI_EXTENDED_INQUIRY_RESULT_IND_T;

#define DM_HCI_EXTENDED_INQUIRY_RESULT_IND \
    ((dm_prim_t)(ENUM_DM_HCI_EXTENDED_INQUIRY_RESULT_IND))

typedef DM_HCI_BD_ADDR_COMMAND_CFM_T DM_HCI_ENHANCED_FLUSH_CFM_T;

typedef HCI_ENHANCED_FLUSH_T DM_HCI_ENHANCED_FLUSH_REQ_T;
#define DM_HCI_ENHANCED_FLUSH_REQ  ((dm_prim_t)(ENUM_DM_HCI_ENHANCED_FLUSH_REQ))

#define DM_HCI_ENHANCED_FLUSH_CFM \
                            ((dm_prim_t)(ENUM_DM_HCI_ENHANCED_FLUSH_CFM))

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Event generated when the link supervision timeout for an ACL changes.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t               type;   /* DM_HCI_LINK_SUPERV_TIMEOUT_IND */
    uint16_t                phandle;
    BD_ADDR_T               bd_addr;
    uint16_t                timeout;
} DM_HCI_LINK_SUPERV_TIMEOUT_IND_T;
#define DM_HCI_LINK_SUPERV_TIMEOUT_IND ((dm_prim_t)(ENUM_DM_HCI_LINK_SUPERV_TIMEOUT_IND))

typedef HCI_SET_AFH_CHANNEL_CLASS_T DM_HCI_SET_AFH_CHANNEL_CLASS_REQ_T;
#define DM_HCI_SET_AFH_CHANNEL_CLASS_REQ ((dm_prim_t)(ENUM_DM_HCI_SET_AFH_CHANNEL_CLASS_REQ))
#define DM_HCI_SET_AFH_CHANNEL_CLASS_CFM ((dm_prim_t)(ENUM_DM_HCI_SET_AFH_CHANNEL_CLASS_CFM))

typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_SET_AFH_CHANNEL_CLASS_CFM_T;

typedef HCI_READ_INQUIRY_SCAN_TYPE_T DM_HCI_READ_INQUIRY_SCAN_TYPE_REQ_T;
#define DM_HCI_READ_INQUIRY_SCAN_TYPE_REQ ((dm_prim_t)(ENUM_DM_HCI_READ_INQUIRY_SCAN_TYPE_REQ))
#define DM_HCI_READ_INQUIRY_SCAN_TYPE_CFM ((dm_prim_t)(ENUM_DM_HCI_READ_INQUIRY_SCAN_TYPE_CFM))

typedef struct
{
    dm_prim_t               type;           /* DM_HCI_READ_INQUIRY_SCAN_TYPE_CFM_T */
    phandle_t               phandle;        /* destination phandle */
    uint8_t                 status;         /* Success or failure - See Note1 */
    uint8_t                 mode ;
} DM_HCI_READ_INQUIRY_SCAN_TYPE_CFM_T;


typedef HCI_WRITE_INQUIRY_SCAN_TYPE_T DM_HCI_WRITE_INQUIRY_SCAN_TYPE_REQ_T;
#define DM_HCI_WRITE_INQUIRY_SCAN_TYPE_REQ ((dm_prim_t)(ENUM_DM_HCI_WRITE_INQUIRY_SCAN_TYPE_REQ))
#define DM_HCI_WRITE_INQUIRY_SCAN_TYPE_CFM ((dm_prim_t)(ENUM_DM_HCI_WRITE_INQUIRY_SCAN_TYPE_CFM))

typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_INQUIRY_SCAN_TYPE_CFM_T;

typedef HCI_READ_INQUIRY_MODE_T DM_HCI_READ_INQUIRY_MODE_REQ_T;
#define DM_HCI_READ_INQUIRY_MODE_REQ ((dm_prim_t)(ENUM_DM_HCI_READ_INQUIRY_MODE_REQ))
#define DM_HCI_READ_INQUIRY_MODE_CFM ((dm_prim_t)(ENUM_DM_HCI_READ_INQUIRY_MODE_CFM))

typedef struct
{
    dm_prim_t               type;           /* DM_HCI_READ_INQUIRY_MODE_CFM_T */
    phandle_t               phandle;        /* destination phandle */
    uint8_t                 status;         /* Success or failure - See Note1 */
    uint8_t                 mode;
} DM_HCI_READ_INQUIRY_MODE_CFM_T;


typedef HCI_WRITE_INQUIRY_MODE_T DM_HCI_WRITE_INQUIRY_MODE_REQ_T;
#define DM_HCI_WRITE_INQUIRY_MODE_REQ ((dm_prim_t)(ENUM_DM_HCI_WRITE_INQUIRY_MODE_REQ))
#define DM_HCI_WRITE_INQUIRY_MODE_CFM ((dm_prim_t)(ENUM_DM_HCI_WRITE_INQUIRY_MODE_CFM))

typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_INQUIRY_MODE_CFM_T;

typedef HCI_READ_PAGE_SCAN_TYPE_T DM_HCI_READ_PAGE_SCAN_TYPE_REQ_T;
#define DM_HCI_READ_PAGE_SCAN_TYPE_REQ ((dm_prim_t)(ENUM_DM_HCI_READ_PAGE_SCAN_TYPE_REQ))
#define DM_HCI_READ_PAGE_SCAN_TYPE_CFM ((dm_prim_t)(ENUM_DM_HCI_READ_PAGE_SCAN_TYPE_CFM))

typedef struct
{
    dm_prim_t               type;           /* DM_HCI_READ_PAGE_SCAN_TYPE_CFM_T */
    phandle_t               phandle;        /* destination phandle */
    uint8_t                 status;         /* Success or failure - See Note1 */
    uint8_t                 mode;
} DM_HCI_READ_PAGE_SCAN_TYPE_CFM_T;


typedef HCI_WRITE_PAGE_SCAN_TYPE_T DM_HCI_WRITE_PAGE_SCAN_TYPE_REQ_T;
#define DM_HCI_WRITE_PAGE_SCAN_TYPE_REQ ((dm_prim_t)(ENUM_DM_HCI_WRITE_PAGE_SCAN_TYPE_REQ))
#define DM_HCI_WRITE_PAGE_SCAN_TYPE_CFM ((dm_prim_t)(ENUM_DM_HCI_WRITE_PAGE_SCAN_TYPE_CFM))

typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_PAGE_SCAN_TYPE_CFM_T;

typedef HCI_READ_AFH_CHANNEL_CLASS_M_T DM_HCI_READ_AFH_CHANNEL_CLASS_M_REQ_T;
#define DM_HCI_READ_AFH_CHANNEL_CLASS_M_REQ ((dm_prim_t)(ENUM_DM_HCI_READ_AFH_CHANNEL_CLASS_M_REQ))
#define DM_HCI_READ_AFH_CHANNEL_CLASS_M_CFM ((dm_prim_t)(ENUM_DM_HCI_READ_AFH_CHANNEL_CLASS_M_CFM))

typedef struct
{
    dm_prim_t               type;           /* DM_HCI_READ_AFH_CHANNEL_CLASS_M_CFM_T */
    phandle_t               phandle;        /* destination phandle */
    uint8_t                 status;         /* Success or failure - See Note1 */
    uint8_t                 class_mode;
} DM_HCI_READ_AFH_CHANNEL_CLASS_M_CFM_T;


typedef HCI_WRITE_AFH_CHANNEL_CLASS_M_T DM_HCI_WRITE_AFH_CHANNEL_CLASS_M_REQ_T;
#define DM_HCI_WRITE_AFH_CHANNEL_CLASS_M_REQ ((dm_prim_t)(ENUM_DM_HCI_WRITE_AFH_CHANNEL_CLASS_M_REQ))
#define DM_HCI_WRITE_AFH_CHANNEL_CLASS_M_CFM ((dm_prim_t)(ENUM_DM_HCI_WRITE_AFH_CHANNEL_CLASS_M_CFM))

typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_AFH_CHANNEL_CLASS_M_CFM_T;

typedef HCI_READ_LOCAL_EXT_FEATURES_T DM_HCI_READ_LOCAL_EXT_FEATURES_REQ_T;
#define DM_HCI_READ_LOCAL_EXT_FEATURES_REQ ((dm_prim_t)(ENUM_DM_HCI_READ_LOCAL_EXT_FEATURES_REQ))
#define DM_HCI_READ_LOCAL_EXT_FEATURES_CFM ((dm_prim_t)(ENUM_DM_HCI_READ_LOCAL_EXT_FEATURES_CFM))

typedef struct
{
    dm_prim_t               type;           /* DM_HCI_READ_LOCAL_EXT_FEATURES_CFM_T */
    phandle_t               phandle;        /* destination phandle */
    uint8_t                 status;         /* Success or failure - See Note1 */
    uint8_t                 page_num;
    uint8_t                 max_page_num;
    uint8_t                 lmp_ext_features[8]; /* As per the specification */
} DM_HCI_READ_LOCAL_EXT_FEATURES_CFM_T;

typedef HCI_READ_AFH_CHANNEL_MAP_T DM_HCI_READ_AFH_CHANNEL_MAP_REQ_T;
#define DM_HCI_READ_AFH_CHANNEL_MAP_REQ ((dm_prim_t)(ENUM_DM_HCI_READ_AFH_CHANNEL_MAP_REQ))
#define DM_HCI_READ_AFH_CHANNEL_MAP_CFM ((dm_prim_t)(ENUM_DM_HCI_READ_AFH_CHANNEL_MAP_CFM))

typedef struct
{
    dm_prim_t               type;           /* DM_HCI_READ_AFH_CHANNEL_MAP_CFM_T */
    phandle_t               phandle;        /* destination phandle */
    uint8_t                 status;         /* Success or failure - See Note1 */
    BD_ADDR_T               bd_addr ;
    uint8_t                 mode;
    uint8_t                 map[10];
} DM_HCI_READ_AFH_CHANNEL_MAP_CFM_T;


typedef HCI_READ_CLOCK_T DM_HCI_READ_CLOCK_REQ_T;
#define DM_HCI_READ_CLOCK_REQ ((dm_prim_t)(ENUM_DM_HCI_READ_CLOCK_REQ))
#define DM_HCI_READ_CLOCK_CFM ((dm_prim_t)(ENUM_DM_HCI_READ_CLOCK_CFM))

typedef struct
{
    dm_prim_t               type;           /* DM_HCI_READ_CLOCK_CFM_T */
    phandle_t               phandle;        /* destination phandle */
    uint8_t                 status;         /* Success or failure - See Note1 */
    BD_ADDR_T               bd_addr ;
    uint32_t                clock;
    uint16_t                accuracy;
} DM_HCI_READ_CLOCK_CFM_T;

#define DM_HCI_READ_INQUIRY_RESPONSE_TX_POWER_LEVEL_REQ \
    ((dm_prim_t)(ENUM_DM_HCI_READ_INQUIRY_RESPONSE_TX_POWER_LEVEL_REQ))
#define DM_HCI_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_REQ \
    ((dm_prim_t)(ENUM_DM_HCI_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_REQ))
#define DM_HCI_READ_INQUIRY_RESPONSE_TX_POWER_LEVEL_CFM \
    ((dm_prim_t)(ENUM_DM_HCI_READ_INQUIRY_RESPONSE_TX_POWER_LEVEL_CFM))
#define DM_HCI_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_CFM \
    ((dm_prim_t)(ENUM_DM_HCI_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_CFM))

typedef HCI_READ_INQUIRY_RESPONSE_TX_POWER_LEVEL_T DM_HCI_READ_INQUIRY_RESPONSE_TX_POWER_LEVEL_REQ_T;
typedef HCI_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_T DM_HCI_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_REQ_T;

typedef struct
{
    /* Always DM_HCI_READ_INQUIRY_RESPONSE_TX_POWER_LEVEL_CFM */
    dm_prim_t               type;
    phandle_t               phandle;        /* destination phandle */
    uint8_t                 status;
    int8_t                 tx_power;
} DM_HCI_READ_INQUIRY_RESPONSE_TX_POWER_LEVEL_CFM_T;

typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_CFM_T;

#define DM_HCI_REM_HOST_SUPPORTED_FEATURES_IND \
    ((dm_prim_t)(ENUM_DM_HCI_REM_HOST_SUPPORTED_FEATURES_IND))
typedef struct
{
    /* Always DM_HCI_REM_HOST_SUPPORTED_FEATURES_IND */
    dm_prim_t               type;
    phandle_t               phandle;        /* destination phandle */
    BD_ADDR_T               bd_addr;        /* ODD event */
    uint16_t                host_features[4];
} DM_HCI_REM_HOST_SUPPORTED_FEATURES_IND_T;

/*! \brief Read Encryption Key Size */
#define DM_HCI_READ_ENCRYPTION_KEY_SIZE_REQ \
    ((dm_prim_t)(ENUM_DM_HCI_READ_ENCRYPTION_KEY_SIZE_REQ))
#define DM_HCI_READ_ENCRYPTION_KEY_SIZE_CFM \
    ((dm_prim_t)(ENUM_DM_HCI_READ_ENCRYPTION_KEY_SIZE_CFM))
typedef HCI_READ_ENCRYPTION_KEY_SIZE_T DM_HCI_READ_ENCRYPTION_KEY_SIZE_REQ_T;

typedef struct
{
    dm_prim_t               type;
    phandle_t               phandle;
    uint8_t                 status;
    BD_ADDR_T               bd_addr;
    uint8_t                 key_size;
} DM_HCI_READ_ENCRYPTION_KEY_SIZE_CFM_T;

/* Read / Write Secure Connections Host Support */

typedef HCI_READ_SECURE_CONNECTIONS_HOST_SUPPORT_T DM_HCI_READ_SECURE_CONNECTIONS_HOST_SUPPORT_REQ_T;
typedef HCI_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT_T DM_HCI_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT_REQ_T;

typedef struct
{
    dm_prim_t type;
    phandle_t phandle;
    uint8_t   status;
    uint8_t   secure_connections_host_support;
} DM_HCI_READ_SECURE_CONNECTIONS_HOST_SUPPORT_CFM_T;

typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT_CFM_T;

/* Authenticated Payload Timeout event */

typedef struct
{
    dm_prim_t       type;
    phandle_t       phandle;
    TP_BD_ADDR_T    tp_addrt;
} DM_HCI_AUTHENTICATED_PAYLOAD_TIMEOUT_EXPIRED_IND_T;

/* Read Authenticated Payload Timeout */

typedef HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_T DM_HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_REQ_T;

typedef struct
{
    dm_prim_t    type;
    phandle_t    phandle;
    uint8_t      status;
    TP_BD_ADDR_T tp_addrt;
    uint16_t     authenticated_payload_timeout;
} DM_HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_CFM_T;

/*-------------------------------------------------------------
  Downstream ULP primitives
 ---------------------------------------------------------------*/
typedef HCI_ULP_SET_EVENT_MASK_T DM_HCI_ULP_SET_EVENT_MASK_REQ_T;
typedef HCI_ULP_READ_LOCAL_SUPPORTED_FEATURES_T DM_HCI_ULP_READ_LOCAL_SUPPORTED_FEATURES_REQ_T;

/*----------------------------------------------------------------------------*
 * API:
 *     DM_HCI_ULP_SET_ADVERTISING_PARAMETERS_REQ_T
 *
 * PURPOSE:
 * This API sets advertisement parameters to the Host and Controller.
 * There is a set of applicable parameters for a given advertising_type.
 * Only the applicable parameters would be considered for the setting.
 * All other parameters would be ignored at both Host and Controller.
 *
 * This API can fail for invalid advertising parameter or when HCI set
 * advertise enable command for "ENABLE" operation is in progress or
 * advertising is already enabled.
 *
 * Upon every successful attempt to set advertisement parameters either through
 * DM_HCI_ULP_SET_ADVERTISING_PARAMETERS_REQ or through ATT_CONNECT_REQ,
 * an event (DM_ULP_ADV_PARAM_UPDATE_IND) will be generted. It is strongly 
 * recommended that succeeding attempts to modify these parameters be 
 * triggered only after DM_ULP_ADV_PARAM_UPDATE_IND has been received.
 *----------------------------------------------------------------------------*/
typedef HCI_ULP_SET_ADVERTISING_PARAMETERS_T DM_HCI_ULP_SET_ADVERTISING_PARAMETERS_REQ_T;


typedef HCI_ULP_READ_ADVERTISING_CHANNEL_TX_POWER_T DM_HCI_ULP_READ_ADVERTISING_CHANNEL_TX_POWER_REQ_T;
typedef HCI_ULP_SET_ADVERTISING_DATA_T DM_HCI_ULP_SET_ADVERTISING_DATA_REQ_T;
typedef HCI_ULP_SET_SCAN_RESPONSE_DATA_T DM_HCI_ULP_SET_SCAN_RESPONSE_DATA_REQ_T;

/*----------------------------------------------------------------------------*
 * API:
 *     HCI_ULP_SET_ADVERTISE_ENABLE_T
 *
 * PURPOSE:
 * This API enables/disables LE advertising(or Truncated advertising) at 
 * the Controller.
 *
 * This API can fail for the following reasons:
 * For "ENABLE" operation,
 * - when HCI set advertise enable command for "ENABLE" operation is in
 *   progress or
 * - advertising is already enabled.
 * For "DISABLE" operation,
 * - when advertising is already disabled.
 *----------------------------------------------------------------------------*/
typedef HCI_ULP_SET_ADVERTISE_ENABLE_T DM_HCI_ULP_SET_ADVERTISE_ENABLE_REQ_T;

typedef HCI_ULP_SET_SCAN_PARAMETERS_T DM_HCI_ULP_SET_SCAN_PARAMETERS_REQ_T;

/* Note: If controller supports extended advertising then filter_duplicates field can
 *       be set to any of these defines 'DM_ULP_EXT_SCAN_FILTER_DUPLICATE_*' else just
 *       the first 2.
 */
typedef HCI_ULP_SET_SCAN_ENABLE_T DM_HCI_ULP_SET_SCAN_ENABLE_REQ_T;

typedef HCI_ULP_CREATE_CONNECTION_CANCEL_T DM_HCI_ULP_CREATE_CONNECTION_CANCEL_REQ_T;
typedef HCI_ULP_READ_WHITE_LIST_SIZE_T DM_HCI_ULP_READ_WHITE_LIST_SIZE_REQ_T;
typedef HCI_ULP_CLEAR_WHITE_LIST_T DM_HCI_ULP_CLEAR_WHITE_LIST_REQ_T;
typedef HCI_ULP_ADD_DEVICE_TO_WHITE_LIST_T DM_HCI_ULP_ADD_DEVICE_TO_WHITE_LIST_REQ_T;
typedef HCI_ULP_REMOVE_DEVICE_FROM_WHITE_LIST_T DM_HCI_ULP_REMOVE_DEVICE_FROM_WHITE_LIST_REQ_T;
typedef HCI_ULP_SET_HOST_CHANNEL_CLASSIFICATION_T DM_HCI_ULP_SET_HOST_CHANNEL_CLASSIFICATION_REQ_T;
typedef HCI_ULP_READ_CHANNEL_MAP_T DM_HCI_ULP_READ_CHANNEL_MAP_REQ_T;
typedef HCI_ULP_READ_REMOTE_USED_FEATURES_T DM_HCI_ULP_READ_REMOTE_USED_FEATURES_REQ_T;
typedef HCI_ULP_ENCRYPT_T DM_HCI_ULP_ENCRYPT_REQ_T;
typedef HCI_ULP_RAND_T DM_HCI_ULP_RAND_REQ_T;
typedef HCI_ULP_READ_SUPPORTED_STATES_T DM_HCI_ULP_READ_SUPPORTED_STATES_REQ_T;
typedef HCI_ULP_RECEIVER_TEST_T DM_HCI_ULP_RECEIVER_TEST_REQ_T;
typedef HCI_ULP_TRANSMITTER_TEST_T DM_HCI_ULP_TRANSMITTER_TEST_REQ_T;
typedef HCI_ULP_TEST_END_T DM_HCI_ULP_TEST_END_REQ_T;
typedef HCI_ULP_READ_RESOLVING_LIST_SIZE_T DM_HCI_ULP_READ_RESOLVING_LIST_SIZE_REQ_T;
typedef HCI_ULP_SET_PRIVACY_MODE_T DM_HCI_ULP_SET_PRIVACY_MODE_REQ_T;
typedef HCI_ULP_ENHANCED_RECEIVER_TEST_T DM_HCI_ULP_ENHANCED_RECEIVER_TEST_REQ_T;
typedef HCI_ULP_ENHANCED_TRANSMITTER_TEST_T DM_HCI_ULP_ENHANCED_TRANSMITTER_TEST_REQ_T;
typedef HCI_ULP_EXT_ADV_SET_DATA_T DM_HCI_ULP_EXT_ADV_SET_DATA_REQ_T;
typedef HCI_ULP_EXT_ADV_SET_SCAN_RESP_DATA_T DM_HCI_ULP_EXT_ADV_SET_SCAN_RESP_DATA_REQ_T;
typedef HCI_ULP_PERIODIC_ADV_SET_DATA_T DM_HCI_ULP_PERIODIC_ADV_SET_DATA_REQ_T;

/*-------------------------------------------------------------
  Upstream ULP primitives
 ---------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_SET_EVENT_MASK_CFM_T;
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_SET_ADVERTISING_PARAMETERS_CFM_T;
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_SET_ADVERTISING_DATA_CFM_T;
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_SET_SCAN_RESPONSE_DATA_CFM_T;
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_SET_ADVERTISE_ENABLE_CFM_T;
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_SET_SCAN_PARAMETERS_CFM_T;
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_SET_SCAN_ENABLE_CFM_T;
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_CREATE_CONNECTION_CANCEL_CFM_T;
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_CLEAR_WHITE_LIST_CFM_T;
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_ADD_DEVICE_TO_WHITE_LIST_CFM_T;
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_REMOVE_DEVICE_FROM_WHITE_LIST_CFM_T;
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_SET_HOST_CHANNEL_CLASSIFICATION_CFM_T;
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_RECEIVER_TEST_CFM_T;
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_TRANSMITTER_TEST_CFM_T;
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_SET_PRIVACY_MODE_CFM_T;
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_ENHANCED_RECEIVER_TEST_CFM_T;
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_ENHANCED_TRANSMITTER_TEST_CFM_T;

typedef struct
{
    dm_prim_t           type;               /* DM_HCI_ULP_READ_LOCAL_SUPPORTED_FEATURES_CFM */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* Success or failure - See Note1 */
    uint8_t             feature_set[8];
} DM_HCI_ULP_READ_LOCAL_SUPPORTED_FEATURES_CFM_T;

typedef struct
{
    dm_prim_t           type;
    phandle_t           phandle;
    uint8_t             status;
    int8_t              tx_power;
} DM_HCI_ULP_READ_ADVERTISING_CHANNEL_TX_POWER_CFM_T;

typedef struct
{
    dm_prim_t           type;
    phandle_t           phandle;
    uint8_t             status;
    uint8_t             white_list_size;
} DM_HCI_ULP_READ_WHITE_LIST_SIZE_CFM_T;

typedef struct
{
    dm_prim_t           type;
    phandle_t           phandle;
    uint8_t             status;
    TYPED_BD_ADDR_T     addrt;
    uint8_t             ulp_channel_map[5];
} DM_HCI_ULP_READ_CHANNEL_MAP_CFM_T;

typedef struct
{
    dm_prim_t           type;               /* DM_HCI_ULP_READ_REMOTE_USED_FEATURES_CFM */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* Success or failure - See Note1 */
    TYPED_BD_ADDR_T     addrt;              /* Bluetooth address */
    uint8_t             feature_set[8];
} DM_HCI_ULP_READ_REMOTE_USED_FEATURES_CFM_T;

typedef struct
{
    dm_prim_t           type;
    phandle_t           phandle;
    uint8_t             status;
    uint8_t             encrypted_data[16];
} DM_HCI_ULP_ENCRYPT_CFM_T;

typedef struct
{
    dm_prim_t           type;
    phandle_t           phandle;
    uint8_t             status;
    uint8_t             random_number[8];
} DM_HCI_ULP_RAND_CFM_T;

typedef struct
{
    dm_prim_t           type;
    phandle_t           phandle;
    uint8_t             status;
    uint8_t             supported_states[8];
} DM_HCI_ULP_READ_SUPPORTED_STATES_CFM_T;

typedef struct
{
    dm_prim_t           type;
    phandle_t           phandle;
    uint8_t             status;
    uint16_t            number_of_packets;
} DM_HCI_ULP_TEST_END_CFM_T;

typedef struct
{
    dm_prim_t           type;               /* DM_HCI_ULP_ADVERTISING_REPORT_IND */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             num_reports;
    uint8_t             event_type;
    TYPED_BD_ADDR_T     current_addrt;
    TYPED_BD_ADDR_T     permanent_addrt;
    uint8_t             length_data;
    uint8_t             *data;
    int8_t              rssi;
} DM_HCI_ULP_ADVERTISING_REPORT_IND_T;

typedef struct
{
    dm_prim_t           type;
    phandle_t           phandle;
    uint8_t             status;
    uint8_t             resolving_list_size;
} DM_HCI_ULP_READ_RESOLVING_LIST_SIZE_CFM_T;

#ifndef EXCLUDE_AE_REPORTS
/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 *      HCI ULP Periodic Advertising Report Event. (0x3E, subevent code: 0x0F)
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t                 type;
    phandle_t                 phandle;
    uint16_t                  sync_handle;
    int8_t                    tx_power;
    int8_t                    rssi;
    uint8_t                   cte_type;
    uint16_t                  adv_data_len; /* Length of adv data (must be 0 to indicate MBLK) */
    MBLK_T                   *adv_data;
} DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_IND_T;
#endif /* EXCLUDE_AE_REPORTS */

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 *      LE Periodic Advertising Sync Transfer Received event. (0x3E, subevent code: 0x18)
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t                 type;
    phandle_t                 phandle;
    uint8_t                   status;
    uint8_t                   adv_sid;
    uint16_t                  sync_handle;
    uint16_t                  service_data;
    TYPED_BD_ADDR_T           adv_addr;
} DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_IND_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 *      HCI ULP Periodic Advertising Sync Lost Event. (0x3E, subevent code: 0x10)
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t                 type;
    phandle_t                 phandle;
    uint16_t                  sync_handle;
} DM_ULP_PERIODIC_SCAN_SYNC_LOST_IND_T;

typedef struct
{
    dm_prim_t                 type;
    uint16_t                  sync_handle;
} DM_ULP_PERIODIC_SCAN_SYNC_LOST_RSP_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 *      HCI ULP Extended Scan Timeout Event. (0x3E, subevent code: 0x11)
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t                 type;
    phandle_t                 phandle;
} DM_ULP_EXT_SCAN_TIMEOUT_IND_T;

/*----------------------------------------------------------------------------*
 * API:
 *     DM_ULP_EXT_ADV_TERMINATED_IND
 *
 * PURPOSE:
 * This API notifies that an extended advertising set has finished advertising due to
 * connection establishment or duration ending or max extended advertising events limit
 * reached.
 *
 * Note: This event will be generated if:
 * 1) Connectable advertising was setup, advertising enabled and
 *    remote side has initiated a connection.
 * 2) Advertising enabled using DM_ULP_EXT_ADV_MULTI_ENABLE_REQ with a non zero
 *    duration that has expired.
 * 3) Advertising enabled using DM_ULP_EXT_ADV_MULTI_ENABLE_REQ with a non zero
 *    max_ea_events limit that has been reached.
 *
 * Note: Field addrt only valid when connection established and field events only valid
 *       when max_ea_events is non zero.
 *----------------------------------------------------------------------------*/

/* Reasons why an advertising set has stopped advertising */
#define DM_ULP_EXT_ADV_TERMINATED_CONN 0      /* Connection established on adv set */
#define DM_ULP_EXT_ADV_TERMINATED_DURATION 1  /* Duration period has ended */
#define DM_ULP_EXT_ADV_TERMINATED_MAX_EVENT 2 /* Max event limit reached */

typedef struct
{
    dm_prim_t               type;         /* Always DM_ULP_EXT_ADV_TERMINATED_IND */
    phandle_t               phandle;      /* Destination phandle */
    uint8_t                 adv_handle;   /* Adv set terminated */
    uint8_t                 reason;       /* Why it was terminated */
    TYPED_BD_ADDR_T         addrt;        /* Peer device address */
    uint8_t                 ea_events;    /* Completed extended advertising events */
    uint8_t                 max_adv_sets; /* Number of adv sets below */

    /* Current state of all advertising sets with regards advertising. Bit set means
       advertising is enabled for that advertising set. Starting at bit 0 to max
       supported advertising sets (e.g. max_adv_sets).
       Note: Bit 0 is for legacy advertising set used by old LE
             connection/advertising APIs (e.g. ADV_HANDLE_FOR_LEGACY_API). */
    uint32_t                adv_bits;

} DM_ULP_EXT_ADV_TERMINATED_IND_T;

/*----------------------------------------------------------------------------*
 * API:
 *     DM_ULP_EXT_SCAN_DURATION_EXPIRED_IND
 *
 * PURPOSE:
 * This API notifies that a scanner has finished scanning due to duration timeout
 * expiring.
 *
 * NOTE: This can only be generated if a duration value has been specified when
 * starting scanning.
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t                 type;
    phandle_t                 phandle;
    uint8_t                   scan_handle;   /* The scanner that has stopped scanning */
    bool_t                    scan_handle_unregistered; /* Did the scanner unregister */
} DM_ULP_EXT_SCAN_DURATION_EXPIRED_IND_T;

/*----------------------------------------------------------------------------*
 * API:
 *     DM_HCI_ULP_CHANNEL_SELECTION_ALGORITHM_IND_T
 *
 * PURPOSE:
 * This API notifies the channel selection algorithm used at the controller
 * after a LE connection is established.
 *
 * NOTE: Application will receive DM_HCI_ULP_CHANNEL_SELECTION_ALGORITHM_IND
 * just after receiveing DM_ACL_OPENED_IND. 
 * Application may choose to enable specific services (isochronous service)
 * based on the channel selection algorithm used at controller.
 *
 * Following are the possible values for channel_selection_algorithm param :
 * value : 0x00 (LE channel selection algorithm #1)
 * value : 0x01 (LE channel selection algorithm #2)
 * value : 0x02-0XFF (Reserved for future use)
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;                       /* DM_HCI_ULP_CHANNEL_SELECTION_ALGORITHM_IND */
    phandle_t       phandle;                    /* destination phandle */
    TP_BD_ADDR_T    tp_addrt;                   /* Peer device address */
    uint8_t         channel_selection_algorithm;
} DM_HCI_ULP_CHANNEL_SELECTION_ALGORITHM_IND_T;

/*----------------------------------------------------------------------------*
 * API:
 *     DM_ULP_ADV_PARAM_UPDATE_IND_T
 *
 * PURPOSE:
 * This API notifies set of advertisement parameters successfully set at the
 * Controller.
 *
 * NOTE: Application should only consider paramenters relevant to the
 * advertising type and ignore the others.
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t           type;               /* DM_ULP_ADV_PARAM_UPDATE_IND_T */
    phandle_t           phandle;            /* destination phandle */
    uint16_t            adv_interval_min;
    uint16_t            adv_interval_max;
    uint8_t             advertising_type;
    uint8_t             own_address_type;
    uint8_t             direct_address_type;
    BD_ADDR_T           direct_address;
    uint8_t             advertising_channel_map;
    uint8_t             advertising_filter_policy;
} DM_ULP_ADV_PARAM_UPDATE_IND_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  Provides an API to allow an application to update change the
 *  Link Layer connection parameters of a connection.
 *
 *  If the controller supports the Connection Parameter Request Procedure, an
 *  HCI command will be invoked to trigger the Link Layer procedure to update
 *  the connection parameters. 
 *
 *  For LE slave : If the remote device does not support or rejects the
 *  Link Layer procedure, the L2CAP signalling procedure to update the parameters
 *  will be attempted as a fallback.
 *  In both these cases note that receiving
 *  DM_BLE_UPDATE_CONNECTION_PARAMETERS_CFM_T could only mean that parameters
 *  are accepted/rejected between Link Layer or L2CAP layers.
 *  If accepted, confirmation does not mean that parameters has been applied
 *  at the link layer. It is DM_HCI_ULP_CONNECTION_UPDATE_COMPLETE_IND which
 *  informs the the new parameter values. Order of arrival of
 *  DM_BLE_UPDATE_CONNECTION_PARAMETERS_CFM_T and
 *  DM_HCI_ULP_CONNECTION_UPDATE_COMPLETE_IND is not fixed.
 *
 *  For LE master : If the remote device does not support or rejects the
 *  Connection Parameter Request Link Layer Procedure, the Connection
 *  Update Link Layer procedure will be used as a fallback.
 *  In return, applications will receive
 *  DM_BLE_UPDATE_CONNECTION_PARAMETERS_CFM_T preceded by
 *  DM_HCI_ULP_CONNECTION_UPDATE_COMPLETE_IND.
 *
 *  RETURNS
 *     DM_BLE_UPDATE_CONNECTION_PARAMETERS_CFM_T
 *---------------------------------------------------------------------------*/

typedef HCI_ULP_CONNECTION_UPDATE_T DM_BLE_UPDATE_CONNECTION_PARAMETERS_REQ_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  Provides parameter update confirmation for the request
 *  DM_BLE_UPDATE_CONNECTION_PARAMETERS_REQ_T.
 *  For additional information, please refer to
 *  DM_BLE_UPDATE_CONNECTION_PARAMETERS_REQ_T.
 *
 *  RETURNS
 *     None
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;   /* DM_BLE_UPDATE_CONNECTION_PARAMETERS_CFM */
    phandle_t           phandle;/* destination phandle */
    uint8_t             status;
    TYPED_BD_ADDR_T     addrt;
} DM_BLE_UPDATE_CONNECTION_PARAMETERS_CFM_T;


/*! \brief DM LE primitives for master or slave to accept/reject 
 *  connection update param req
 *
 *  Provides an indication to application to accept/reject connection parameters
 *  update request from a peripheral device which has used either the Link Layer
 *  or L2CAP update procedure.
 *
 *  In the case of a Link Layer initiated update, the L2CAP Signal ID shall be
 *  set to 0.
 *
 *  RETURNS
 *     A RSP
*/

typedef struct
{
    dm_prim_t type;                 /*!< DM_BLE_ACCEPT_CONNECTION_PAR_UPDATE_IND */
    phandle_t phandle;              /*!< phandle for the response */
    TYPED_BD_ADDR_T bd_addrt;       /*!< Bluetooth device address of remote device */
    l2ca_identifier_t signal_id;    /*!< L2CAP Signal ID - application must respond back to generate a response signal */
    uint16_t conn_interval_min;     /*!< Minimum allowed connection interval
                                         as number of 1.25 ms */
    uint16_t conn_interval_max;     /*!< Maximum allowed connection interval
                                         as number of 1.25 ms */
    uint16_t conn_latency;          /*!< connection slave latency */
    uint16_t supervision_timeout;   /*!< link timeout value as number 0f 10 ms */
} DM_BLE_ACCEPT_CONNECTION_PAR_UPDATE_IND_T;


/*! \brief DM LE primitives for application to accept/reject connection update param

 *  Provides a response to DM with result for accept/reject of connection parameters
 *  Please note that connection listed in this primitive should be exactly same as
 *  given in DM_BLE_ACCEPT_CONNECTION_PAR_UPDATE_IND_T primitive.
 *
 *  An L2CAP Signal ID of 0 indicates that the Link Layer update procedure has been used.
 *
 *  RETURNS
 *     A RSP
*/
typedef struct
{
    dm_prim_t type;                 /*!< DM_BLE_CONNECTION_PAR_UPDATE_RSP */
    l2ca_identifier_t signal_id;    /*!< L2CAP Signal ID */
    TYPED_BD_ADDR_T bd_addrt;       /*!< Bluetooth device address  of remote device required to generate connection handle*/
    uint16_t conn_interval_min;     /*!< Minimum allowed connection interval
                                         as number of 1.25 ms */
    uint16_t conn_interval_max;     /*!< Maximum allowed connection interval
                                         as number of 1.25 ms */
    uint16_t conn_latency;          /*!< connection slave latency */
    uint16_t supervision_timeout;   /*!< link timeout value as number of 10 ms */
    uint16_t result;                /*!< L2CAP_CONNECTION_PARAMETER_UPDATE_ACCEPT or HCI_SUCCESS - if parameters are acceptable,
                                      !< L2CAP_CONNECTION_PARAMETER_UPDATE_REJECT or
                                      !< HCI_ERROR_UNACCEPTABLE_CONN_PARAMETERS - non-acceptable */
} DM_BLE_ACCEPT_CONNECTION_PAR_UPDATE_RSP_T;


typedef struct
{
    dm_prim_t           type;               /* DM_HCI_ULP_CONNECTION_UPDATE_COMPLETE_IND */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;
    TYPED_BD_ADDR_T     addrt;
    uint16_t            conn_interval;
    uint16_t            conn_latency;
    uint16_t            supervision_timeout;
} DM_HCI_ULP_CONNECTION_UPDATE_COMPLETE_IND_T;


/*-------------------------------------------------------------
  Downstream CSB primitives
 ---------------------------------------------------------------*/

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  Provides an API to allow an application to reserve LT_ADDR for CSB.
 *  Reserving LT_ADDR much early will increase the possibility of LT_ADDR
 *  availability.
 *
 *  RETURNS
 *     DM_HCI_SET_RESERVED_LT_ADDR_CFM_T
 *---------------------------------------------------------------------------*/
typedef HCI_SET_RESERVED_LT_ADDR_T DM_HCI_SET_RESERVED_LT_ADDR_REQ_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  Provides an API to allow an application to delete a reserved LT_ADDR for
 *  CSB. After deleting, LT_ADDR is available to be reserved.
 *
 *  RETURNS
 *     DM_HCI_DELETE_RESERVED_LT_ADDR_CFM_T
 *---------------------------------------------------------------------------*/
typedef HCI_DELETE_RESERVED_LT_ADDR_T DM_HCI_DELETE_RESERVED_LT_ADDR_REQ_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  A command to be used to enable CSB transmitter.
 *
 *  RETURNS
 *     DM_HCI_SET_CSB_CFM_T
 *---------------------------------------------------------------------------*/
typedef HCI_SET_CSB_T DM_HCI_SET_CSB_REQ_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  A command to be used to send CSB data.
 *  Data will be transmitted based on packet_type selected in
 *  DM_HCI_SET_CSB_REQ_T. If no data is set, transmitter will send NULL packet.
 *
 *  RETURNS
 *     DM_HCI_SET_CSB_DATA_CFM_T
 *---------------------------------------------------------------------------*/
typedef HCI_SET_CSB_DATA_T DM_HCI_SET_CSB_DATA_REQ_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  Read current synchronization train parameter.
 *
 *  RETURNS
 *     DM_HCI_READ_SYNCHRONIZATION_TRAIN_PARAMS_CFM_T
 *---------------------------------------------------------------------------*/
typedef HCI_READ_SYNCHRONIZATION_TRAIN_PARAMS_T DM_HCI_READ_SYNCHRONIZATION_TRAIN_PARAMS_REQ_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  Update synchronization train parameter with specified value
 *
 *  RETURNS
 *     DM_HCI_WRITE_SYNCHRONIZATION_TRAIN_PARAMS_CFM_T
 *---------------------------------------------------------------------------*/
typedef HCI_WRITE_SYNCHRONIZATION_TRAIN_PARAMS_T DM_HCI_WRITE_SYNCHRONIZATION_TRAIN_PARAMS_REQ_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  Start synchronization train
 *
 *  RETURNS
 *     None
 *---------------------------------------------------------------------------*/
typedef HCI_START_SYNCHRONIZATION_TRAIN_T DM_HCI_START_SYNCHRONIZATION_TRAIN_REQ_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  Configure data path in a given direction between the Controller and the
 *  Host.
 *
 *  RETURNS
 *     DM_HCI_CONFIGURE_DATA_PATH_CFM_T
 *---------------------------------------------------------------------------*/
typedef HCI_CONFIGURE_DATA_PATH_T DM_HCI_CONFIGURE_DATA_PATH_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_HCI_CONFIGURE_DATA_PATH_CFM
 *---------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_CONFIGURE_DATA_PATH_CFM_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  Start paging with specified BD_ADDR.
 *
 *  RETURNS
 *     DM_HCI_TRUNCATED_PAGE_CFM_T
 *---------------------------------------------------------------------------*/
typedef HCI_TRUNCATED_PAGE_T DM_HCI_TRUNCATED_PAGE_REQ_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  Cancel the ongoing truncated paging process.
 *
 *  RETURNS
 *     DM_HCI_TRUNCATED_PAGE_CANCEL_CFM_T
 *---------------------------------------------------------------------------*/
typedef HCI_TRUNCATED_PAGE_CANCEL_T DM_HCI_TRUNCATED_PAGE_CANCEL_REQ_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  A command to be used to enable CSB receiver.
 *  It is important to set parameters based on received synchronization train
 *  parameters.
 *
 *  RETURNS
 *     DM_HCI_SET_CSB_RECEIVE_CFM_T
 *---------------------------------------------------------------------------*/
typedef HCI_SET_CSB_RECEIVE_T DM_HCI_SET_CSB_RECEIVE_REQ_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  A command to be used to enable synchronization train reception.
 *
 *  RETURNS
 *     None
 *---------------------------------------------------------------------------*/
typedef HCI_RECEIVE_SYNCHRONIZATION_TRAIN_T DM_HCI_RECEIVE_SYNCHRONIZATION_TRAIN_REQ_T;

/*-------------------------------------------------------------
  Upstream CSB primitives
 ---------------------------------------------------------------*/

typedef struct
{
    dm_prim_t           type;             /* Prim ID */
    phandle_t           phandle;          /* destination phandle */
    uint8_t             status;           /* Success or failure */
    uint8_t             lt_addr;
    uint16_t            interval;
} DM_HCI_SET_CSB_CFM_T;

typedef struct
{
    dm_prim_t           type;              /* Prim ID */
    phandle_t           phandle;          /* destination phandle */
    uint8_t             status;         /* Success or failure - See Note1 */
    uint8_t             lt_addr;
} DM_HCI_SET_CSB_DATA_CFM_T;

typedef struct
{
    dm_prim_t           type;              /* Prim ID */
    phandle_t           phandle;          /* destination phandle */
    uint8_t             status;         /* Success or failure - See Note1 */
    uint8_t             lt_addr;
} DM_HCI_SET_RESERVED_LT_ADDR_CFM_T;

typedef struct
{
    dm_prim_t           type;              /* Prim ID */
    phandle_t           phandle;          /* destination phandle */
    uint8_t             status;         /* Success or failure - See Note1 */
    uint8_t             lt_addr;
} DM_HCI_DELETE_RESERVED_LT_ADDR_CFM_T;

typedef struct
{
    dm_prim_t           type;              /* Prim ID */
    phandle_t           phandle;          /* destination phandle */
    uint8_t             status;         /* Success or failure - See Note1 */
    uint16_t            sync_train_ref_interval;
    uint32_t            sync_train_timeout;
    uint8_t             service_data;
} DM_HCI_READ_SYNCHRONIZATION_TRAIN_PARAMS_CFM_T;

typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* Success or failure - See Note1 */
    uint16_t            sync_train_ref_interval;
} DM_HCI_WRITE_SYNCHRONIZATION_TRAIN_PARAMS_CFM_T;

typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* Success or failure - See Note1 */
    BD_ADDR_T           bd_addr;            /* Remote device BD address */
    uint8_t             lt_addr;            /* Reserved LT_ADDR */
} DM_HCI_SET_CSB_RECEIVE_CFM_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  LC will send synchronization train event to application when synchronization
 *  train packet is received with a non-zero LT_ADDR or LC fails to
 *  receive a synchronization train packet for synchronization_scanTO period.
 *
 *  RETURNS
 *     None
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* Success or failure - See Note1 */
    BD_ADDR_T           bd_addr;            /* Remote device BD Address */
    uint32_t            clock_offset;       /* Difference with master clock */
    uint8_t             map[10];            /* AFH map data */
    uint8_t             lt_addr;            /* Reserved LT_ADRR */
    uint32_t            next_broadcast_instant; /* Clock of a future broadcast */
    uint16_t            csb_interval;
    uint8_t             service_data;
} DM_HCI_RECEIVE_SYNCHRONIZATION_TRAIN_CFM_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  This event is sent to application on every CSB RX instant.
 *  With receive_status set to zero means packet is received successfully.
 *
 *  RETURNS
 *     None
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* destination phandle */
    BD_ADDR_T           bd_addr;            /* Remote device BD address */
    uint8_t             lt_addr;
    uint32_t            clock;              /* clock when data is received */
    uint32_t            offset;
    uint8_t             receive_status;
    uint8_t             fragment;
    uint8_t             data_length;
    /* 
     * The pointers below, point to a byte array of size
     * HCI_CSB_RECV_BYTES_PER_PTR.
     */
    uint8_t            *data_part[HCI_CSB_RECV_PACKET_PTRS];
} DM_HCI_CSB_RECEIVE_IND_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  This event is applicable to both CSB transmitter and receiver.
 *  In case of CSB transmitter if LC fails to perform CSB TX operation due to
 *  high priority activity for the period of supervision_timeout then this
 *  timeout event is sent.
 *
 *  In case of receiver if LC fails to receive any data packet for the period
 *  of supervision_timeout then this timeout event is sent.
 *
 *  RETURNS
 *     DM_HCI_CSB_RX_TIMEOUT_RSP_T for CSB receiver.
 *     DM_HCI_CSB_TX_TIMEOUT_RSP_T for CSB transmitter.
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* destination phandle */
    BD_ADDR_T           bd_addr;            /* remote device BD address */
    uint8_t             lt_addr;
} DM_HCI_CSB_TIMEOUT_IND_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  Firmware will send this event to application whenever LC switch to new AFH
 *  map data along with current AFH map data is being used.
 *
 *  RETURNS
 *     None
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             map[10];            /* AFH map data */
} DM_HCI_CSB_CHANNEL_MAP_CHANGE_IND_T;


/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  This event will be generated if the slave BR/EDR Controller responds to a
 *  page but does not receive the master FHS packet.
 *
 *  RETURNS
 *     None
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* destination phandle */
} DM_HCI_SLAVE_PAGE_RESPONSE_TIMEOUT_IND_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  In case of CSB transmitter, firmware will send clock and AFH map data
 *  availability on mentioned clock to application. Application might use this
 *  information to set new AFH map to firmware.
 *  NOTE:
 *      Firmware having the feature to register VSC (Bluestack Vendor Specific
 *      commands and events handling) interface will not report this event.
 *
 *  RETURNS
 *     None
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* destination phandle */
    uint32_t            clock;
    uint8_t             map[10];            /* AFH map data */
} DM_HCI_CSB_AFH_MAP_AVAILABLE_IND_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  In case of CSB transmitter, application should send this primitive once
 *  DM_HCI_CSB_TIMEOUT_IND event is received.
 *
 *  RETURNS
 *     None
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             lt_addr;
} DM_HCI_CSB_TX_TIMEOUT_RSP_T;

/*---------------------------------------------------------------------------*
 *  PURPOSE
 *  In case of CSB receiver, application should send this primitive once
 *  DM_HCI_CSB_TIMEOUT_IND event is received.
 *
 *  RETURNS
 *     None
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             lt_addr;
    BD_ADDR_T           bd_addr;
} DM_HCI_CSB_RX_TIMEOUT_RSP_T;

/*------------------------------------------------------------------------
 *  PURPOSE
 *  Bluestack needs to be ESSENTIALLY notified through this primitive 
 *  once the controller has booted up. The Layer below Bluestack (host transport)
 *  would need to frame this primitive once the transport link is up.
 *
 *  RETURNS
 *     None
 *-----------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;           /* DM_CONTROLLER_READY_NTF */
    uint8_t             status;         /* Success or failure */
} DM_CONTROLLER_READY_NTF_T;


typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_START_SYNCHRONIZATION_TRAIN_CFM_T;
typedef DM_HCI_BD_ADDR_COMMAND_CFM_T DM_HCI_TRUNCATED_PAGE_CFM_T;
typedef DM_HCI_BD_ADDR_COMMAND_CFM_T DM_HCI_TRUNCATED_PAGE_CANCEL_CFM_T;

/*-------------------------------------------------------------
  DM Crypto pubilc defines 
 ---------------------------------------------------------------*/

#define DM_CRYPTO_ECC_P192                  1   /* Type ECC-192 */
#define DM_CRYPTO_ECC_P256                  2   /* Type ECC-256 */
#define DM_CRYPTO_PUBLIC_KEY_SIZE           32  /* 64 bytes */
#define DM_CRYPTO_PRIVATE_KEY_SIZE          16  /* 32 bytes */
#define DM_CRYPTO_LOCAL_PVT_KEY_SIZE        16  /* 32 bytes */
#define DM_CRYPTO_REMOTE_PUB_KEY_SIZE       32  /* 64 bytes */
#define DM_CRYPTO_SECRET_KEY_SIZE           16  /* 32 bytes */
#define DM_CRYPTO_AES_DATA_SIZE             8   /* 16 bytes */
#define DM_CRYPTO_AES_KEY_SIZE              8   /* 16 bytes */
#define DM_CRYPTO_SHA_DATA_SIZE             16  /* 32 bytes */
#define DM_CRYPTO_SHA_HASH_SIZE             16  /* 32 bytes */
#define DM_CRYPTO_AES_NONCE                 8   /* 16 bytes */

/* Operation types, used to specify more data for hash generation */
#define DM_CRYPTO_SINGLE_BLOCK              0
#define DM_CRYPTO_DATA_START                1
#define DM_CRYPTO_DATA_CONTI                2
#define DM_CRYPTO_DATA_END                  3

/* Crypto status */
#define DM_CRYPTO_SUCCESS                   0 /* Success status */
#define DM_CRYPTO_INT_SUCCESS               1 /* Interim success status */
/* New crypto request initiated when one such is in progress */
#define DM_CRYPTO_BUSY                      2 
/* In case the downstream APIs were called with invalid parameters */
#define DM_CRYPTO_INVALID_PARAM             3 
#define DM_CRYPTO_GENERIC_FAIL              4 /* General Failure status */

typedef uint16_t dm_crypto_flags_t;

/* crypto flags */
#define DM_CRYPTO_FLAGS_NONE                    ((dm_crypto_flags_t) 0x0000)
#define DM_CRYPTO_FLAGS_BIG_ENDIAN_COUNTER      ((dm_crypto_flags_t) 0x0001)

/*-------------------------------------------------------------
  Downstream DM Crypto primitives
 ---------------------------------------------------------------*/

/*----------------------------------------------------------------------------*
 *      PURPOSE
 *      This API allows application to generate a ECC public-private key pair.
 *      Appropriate key_type field needs to be set by the caller to indicate the
 *      crypto block regarding the type of ECC algo (ECC-192/ECC-256) to be used
 *      for the public-private key generation. Based on the type field either a
 *      384 bit (ECC-192) or 512 bit (ECC-256) of public key is generated along
 *      with a 192 bit (ECC-192) or 256 bit (ECC-256) private key. A call to
 *      this API while the previous request is outstanding will result
 *      in 'DM_CRYPTO_BUSY' in its confirmation event.
 *
 *      Completion of this operation is notified to the application using
 *      DM_CRYPTO_GENERATE_PUBLIC_PRIVATE_KEY_CFM_T event.
 *
 *      RETURNS
 *      None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;           /* DM_CRYPTO_GENERATE_PUBLIC_PRIVATE_KEY_REQ */
    phandle_t       phandle;        /* Destination phandle */
    uint8_t         key_type;       /* DM_CRYPTO_ECC_P192/DM_CRYPTO_ECC_P256 */
    context_t       context;        /* Opaque context returned in CFM */
} DM_CRYPTO_GENERATE_PUBLIC_PRIVATE_KEY_REQ_T;

/*----------------------------------------------------------------------------*
 *      PURPOSE
 *      This API allows application to generate a shared secret (ECDH_key).
 *      Appropriate key_type field needs to be set by the caller to indicate
 *      the crypto block regarding the ECC algo (ECC-192/ECC-256) to be used
 *      for the ECDH_key generation. Along with the type the application needs
 *      to pass the 384 bit (ECC-192) or 512 bit public key (ECC-256) and the
 *      192 bit (ECC-192) or 256 bit (ECC-256) private key. A call to
 *      this API while the previous request is outstanding will result
 *      in 'DM_CRYPTO_BUSY' in its confirmation event.
 *
 *      Completion of this operation is notified to the application using
 *      DM_CRYPTO_GENERATE_SHARED_SECRET_KEY_CFM_T event.
 *
 *      For ECC_192 bit shared secret key generation scenario:
 *      The Private Key with a UINT16 representation:
 *      M(1e) --------------------------------------------------L(6d)
 *      |1e63|6ca7|90b5|0f68|f15d|8dbe|8624|4e30|9211|d635|de00|e16d|
 *      has to be filled in "local_private_key" array in following format:
 *      local_private_key[0] = 0xe16d;
 *      local_private_key[1] = 0xde00;
 *              ....
 *              ....
 *      local_private_key[11] = 0x1e63;
 *
 *      Similarly the Public Key with a UINT16 representation:
 *      M(15)---------------------------------------------------L(ed)
 *      |1520|7009|9844|21a6|586f|9fc3|fe7e|4329|d280|9ea5|1125|f8ed|<-- Public key X
 *      M(b0)---------------------------------------------------L(25)
 *      |b09d|42b8|1bc5|bd00|9f79|e4b5|9dbb|aa85|7fca|856f|b9f7|ea25|<-- Public key Y
 *      has to be filled in "remote_public_key" array in the following format:
 *      remote_public_key[0] = 0xf8ed;
 *      remote_public_key[1] = 0x1125;
 *              ....
 *              ....
 *      remote_public_key[11] = 0x1520;
 *      remote_public_key[12] = 0xea25;
 *      remote_public_key[13] = 0xb9f7;
 *              ....
 *              ....
 *      remote_public_key[23] = 0xb09d;
 *
 *      RETURNS
 *      None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;                                               /* DM_CRYPTO_GENERATE_SHARED_SECRET_KEY_REQ */
    phandle_t       phandle;                                            /* destination phandle */
    uint8_t         key_type;                                           /* DM_CRYPTO_ECC_P192/DM_CRYPTO_ECC_P256 */
    context_t       context;                                            /* Opaque context returned in CFM */
    uint16_t        local_private_key[DM_CRYPTO_LOCAL_PVT_KEY_SIZE];    /* Local private key, zero if status is failure */
    uint16_t        remote_public_key[DM_CRYPTO_REMOTE_PUB_KEY_SIZE];   /* Remote public key, zero if status is failure */
} DM_CRYPTO_GENERATE_SHARED_SECRET_KEY_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      This API allows application to perform AES_128 encryption on 128 bit
 *      of data with a 128 bit of encryption key. The flags field is reserved
 *      for future use. A call to this API while the previous request is 
 *      outstanding will result in 'DM_CRYPTO_BUSY' in its confirmation event.
 *
 *      Completion of this operation is notified to application using
 *      DM_CRYPTO_ENCRYPT_CFM_T event.
 *
 *      The plain text with a UINT16 representation:
 *      M(00)-------------------------------L(ff)
 *      |0011|2233|4455|6677|8899|aabb|ccdd|eeff|
 *      has to be filled in "data" array in the following format:
 *      data[0] = 0xeeff;
 *      data[1] = 0xccdd;
 *          ....
 *          ....
 *      data[7] = 0x0011;
 *
 *      The encryption key with a UINT16 representation:
 *      M(00)-------------------------------L(0f)
 *      |0001|0203|0405|0607|0809|0a0b|0c0d|0e0f|
 *      has to be filled in "encryption_key" array in the following format:
 *      encryption_key[0] = 0x0e0f;
 *      encryption_key[1] = 0x0c0d;
 *          ....
 *          ....
 *      encryption_key[7] = 0x0001;
 *
 *      RETURNS
 *      None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;                                       /* DM_CRYPTO_ENCRYPT_REQ */
    phandle_t       phandle;                                    /* Destination phandle */
    uint8_t         flags;                                      /* reserved */
    context_t       context;                                    /* Opaque context returned in CFM */
    uint16_t        data[DM_CRYPTO_AES_DATA_SIZE];              /* Data to be encrypted */
    uint16_t        encryption_key[DM_CRYPTO_AES_KEY_SIZE];     /* Encryption key */
} DM_CRYPTO_ENCRYPT_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      This API allows application to perform SHA-256 hash on 32 bytes block
 *      of data. Appropriate 'operation' value needs to be set in the API to
 *      indicate the crypto block to expect more data from the user before 
 *      generation of final hash value.
 *
 *      DM_CRYPTO_SINGLE_BLOCK: operation type to be used to generate hash for
 *      single block <=32 bytes of application data.
 *
 *      DM_CRYPTO_DATA_START: operation type to be used to pass first block
 *      of 32 bytes of data for data length more than 32 bytes.
 *
 *      DM_CRYPTO_DATA_CONTI: operation type to be used to pass intermediate
 *      block of 32 bytes of data for data length more than 32 bytes.
 *
 *      DM_CRYPTO_DATA_END: operation type to be used to pass final block of 
 *      remaining data with length <= 32 bytes.
 *
 *      A call to this API while the previous request is outstanding will result
 *      in 'DM_CRYPTO_BUSY' in its confirmation event.
 *
 *      The flags field is reserved for for future use. Completion of this 
 *      operation is notified to application using DM_CRYPTO_HASH_CFM_T event.
 *
 *      The even length application data with a UINT16 representation:
 *      M(61)-------------------------------L(70)
 *      |6162|6364|6566|6768|696a|6b6c|6d6e|6f70|
 *      has to be filled in "data" array in the following format:
 *      data[0] = 0x6f70;
 *      data[1] = 0x6d6e;
 *          ....
 *          ....
 *      data[7] = 0x6162;
 *
 *      The "data_length" is represented in number of bytes.
 *      data_length = 16(0x10)
 *
 *      The odd length application data with a UINT16 representation:
 *       M(61)------------------------------L(6f)
 *      |XX61|6263|6465|6667|6869|6a6b|6c6d|6e6f|
 *      has to be filled in "data" array in the following format:
 *      data[0] = 0x6e6f;
 *      data[1] = 0x6c6d;
 *          ....
 *          ....
 *      data[7] = 0x0061;
 *
 *      The "data_length" is represented in number of bytes.
 *      data_length = 15(0x0F)
 *
 *      RETURNS
 *      None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;                               /* DM_CRYPTO_HASH_REQ */
    phandle_t       phandle;                            /* Destination phandle */
    uint8_t         operation;                          /* Operation types mentioned above */
    uint8_t         flags;                              /* Reserved */
    context_t       context;                            /* Opaque context returned in CFM */
    uint16_t        data_size;                          /* Data size of buffer */
    uint16_t        data[DM_CRYPTO_SHA_DATA_SIZE];      /* Data to be hashed */
} DM_CRYPTO_HASH_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      This API allows application to perform AES_128 decryption on 128 bit
 *      of cipher text with a 128 bit of encryption key. The flags field is
 *      reserved for future use.
 *
 *      Completion of this operation is notified to application using
 *      DM_CRYPTO_DECRYPT_CFM_T event.
 *
 *      The cipher_text with a UINT16 representation:
 *      M(69)-------------------------------L(5a)
 *      |69c4|e0d8|6a7b|0430|d8cd|b780|70b4|c55a|
 *      has to be filled in "cipher_text" array in the following format:
 *      cipher_text[0] = 0xc55a;
 *      cipher_text[1] = 0x70b4;
 *      ....
 *      ....
 *      cipher_text[7] = 0x69c4;
 *
 *      The decryption key with a UINT16 representation:
 *      M(00)-------------------------------L(0f)
 *      |0001|0203|0405|0607|0809|0a0b|0c0d|0e0f|
 *      has to be filled in "decryption_key" array in the following format:
 *      decryption_key[0] = 0x0e0f;
 *      decryption_key[1] = 0x0c0d;
 *      ....
 *      ....
 *      decryption_key[7] = 0x0001;
 *
 * RETURNS
 * None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t        type;                                   /* DM_CRYPTO_DECRYPT_REQ */
    phandle_t        phandle;                                /* Destination phandle */
    context_t        context;                                /* Opaque context returned in CFM */
    uint8_t          flags;                                  /* Reserved */
    uint16_t         cipher_text[DM_CRYPTO_AES_DATA_SIZE];   /* Data to be decrypted */
    uint16_t         decryption_key[DM_CRYPTO_AES_KEY_SIZE]; /* Decryption key */
} DM_CRYPTO_DECRYPT_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      This API allows application to encrypt or decrypt data using the
 *      AES128-CTR algorithm.
 *
 *      Completion of this operation is notified to application using
 *      DM_CRYPTO_AES_CTR_CFM_T event.
 *
 *      flags(dm_crypto_flags_t):
 *           Provides control over how the cryptographic algorithm is run
 *           e.g. whether parameter counter is big or little endian.
 *           DM_CRYPTO_FLAGS_NONE for the standard operation or
 *           DM_CRYPTO_FLAGS_BIG_ENDIAN_COUNTER to concatenate the counter value
 *           to the upper bits of the initial vector.
 *
 *  Sample data:
 *
 *      flags = 0x01 (DM_CRYPTO_FLAGS_BIG_ENDIAN_COUNTER)
 *
 *      The secret_key with a UINT16 representation:
 *      M(01)-------------------------------L(ef)
 *      |0123|4567|89ab|cdef|0123|4567|89ab|cdef
 *      has to be filled in "secret_key" array in the following format:
 *      secret_key[0] = 0xcdef;
 *      secret_key[1] = 0x89ab;
 *      ....
 *      ....
 *      secret_key[7] = 0x0123;
 *
 *      The nonce with a UINT16 representation:
 *      M(00)-------------------------------L(07)
 *      |0000|0000|0000|0000|0001|0203|0405|0607
 *      has to be filled in "nonce" array in the following format:
 *      nonce[0] = 0x0607;
 *      nonce[1] = 0x0405;
 *      ....
 *      ....
 *      nonce[7] = 0x0000;
 *
 *      The data with a UINT16 representation:
 *      M(53)-------------------------------L(65)
 *      |536f|6d65|6f6e|6527|7320|476f|6f67|6c65|2048|6561|6470|686f|6e65
 *      has to be filled in "data" array in the following format:
 *      data[0] = 0x6e65;
 *      data[1] = 0x686f;
 *      ....
 *      ....
 *      data[12] = 0x536f;
 *
 *      data_len: Number of uint16 words.
 *      The MAX input data allowed is 32 uint16 (64 bytes).
 *
 *      For the output of above sample data see prim DM_CRYPTO_AES_CTR_CFM_T
 *      description.
 *
 * RETURNS
 * None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t          type;                        /* DM_CRYPTO_AES_CTR_REQ */
    phandle_t          phandle;                     /* Destination phandle */
    context_t          context;                     /* Opaque context returned in CFM */
    uint32_t           counter;                     /* Initial counter value */
    dm_crypto_flags_t  flags;                       /* See crypto flags */
    uint16_t           secret_key[DM_CRYPTO_AES_KEY_SIZE]; /* key for encryption/decryption */
    uint16_t           nonce[DM_CRYPTO_AES_NONCE];  /* Nonce value */
    /* Number of uint16 input data (Plain or cipher text) length; Max 32 */
    uint16_t           data_len;
    uint16_t           *data;                       /* Input data */
} DM_CRYPTO_AES_CTR_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Encrypt/Decrypt SIRK(Set Identity Resolving Key) as per Coordinated Set 
 *      Identification Service(CSIS) security requirement.
 *      If the 'sirk_key' contains plain SIRK, DM_SM_SIRK_OPERATION_CFM_T returns
 *      the encrypted SIRK in 'sirk_key'.
 *      If the 'sirk_key' contains encrypted SIRK, DM_SM_SIRK_OPERATION_CFM_T
 *      returns the decrypted SIRK in 'sirk_key'.
 *
 *  Sample data:
 *
 *      The sirk_key with a UINT8 representation:
 *      M(45)----------------------------L(cd)
 *      |457d7d09 21a1fd22 cecd8c86 dd72cccd|
 *      has to be filled in "sirk_key" array in the following format:
 *      sirk_key[0] = 0x45;
 *      sirk_key[1] = 0x7d;
 *      sirk_key[2] = 0x7d;
 *      sirk_key[3] = 0x09;
 *      ....
 *      ....
 *      sirk_key[14] = 0xcc;
 *      sirk_key[15] = 0xcd;
 *
 * RETURNS
 *      None
 *----------------------------------------------------------------------------*/

/* SIRK size in octets */
#define DM_SM_SIRK_KEY_SIZE             (16)
typedef struct
{
    dm_prim_t       type;                            /* DM_SM_SIRK_OPERATION_REQ */
    phandle_t       phandle;                         /* Destination phandle */
    context_t       context;                         /* Opaque context returned from REQ */
    TP_BD_ADDR_T    tp_addrt;                        /* Transport type would always be LE.
                                                         However fat BD addr is used since it
                                                         is with most informative and therefore
                                                         good to have on interface. */
    uint8_t         flags;                           /* Reserved */
    uint8_t         sirk_key[DM_SM_SIRK_KEY_SIZE];   /* Data to be hashed */
} DM_SM_SIRK_OPERATION_REQ_T;

/* This mask is to be used to clear any previously set configuration using DM_SM_CONFIG_REQ API.*/
#define DM_SM_CONFIG_MASK_INVALID               0x0000
/* This flag allows application to get DM_SM_KEY_REQUEST_IND everytime when the encryption
 * is requested. It gives chance to application to provide it's own LTK. If application
 * doesn't provide LTK in the response, bluestack will be using SMDB LTK if present or else
 * it will send negative response to the request for encrytpion.
 */
#define DM_SM_CONFIG_MASK_APP_LTK_QUERY_ENABLE  0x0001

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_SM_CONFIG_REQ is used to configure various options into security manager.
 *     As a response to this, DM_SM_CONFIG_CFM will be received by application.
 *
 * RETURNS
 *      None
 *-----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t   type;           /* DM_SM_CONFIG_REQ */
    phandle_t   phandle;        /* Destination phandle */
    uint16_t    config_mask;    /* Configuration mask, note that this will override any previously set configuration.
                                 * Please refer to DM_SM_CONFIG_MASK_* for more details. */
    uint8_t     length;         /* Shall not be used, reserved for future use */
    uint8_t    *params;         /* Shall not be used, reserved for future use */
} DM_SM_CONFIG_REQ_T;

/* Request to configure SM is successfull */
#define DM_SM_CONFIG_STATUS_SUCCESS 0x00
/* Request to configure SM has failed.*/
#define DM_SM_CONFIG_STATUS_FAILURE 0x01
/* Request to configure SM has failed because SM is currently busy doing some of the already configured
 * procedure which cannot be interrupted in the middle.*/
#define DM_SM_CONFIG_STATUS_BUSY    0x02

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      Confirmation for DM_SM_CONFIG_REQ API call.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t   type;     /* DM_SM_CONFIG_CFM */
    phandle_t   phandle;  /* Destination phandle */
    uint8_t     status;   /* Status of the request */
} DM_SM_CONFIG_CFM_T;

/*-------------------------------------------------------------
  DM SM ENCRYPT public defines
 ---------------------------------------------------------------*/

#define DM_SM_ENCRYPT_KEY_LEN                       (16)
#define DM_SM_ENCRYPT_IV_LEN                        (8)
#define DM_SM_ENCRYPT_RAND_LEN                      (5)
#define DM_SM_ENCRYPT_MIC_LEN                       (4)

#define DM_SM_ENCRYPT_DATA_LEN                      (245)
#define DM_SM_ENCRYPT_DATA_PER_PTR                  HCI_VAR_ARG_POOL_SIZE
#define DM_SM_ENCRYPT_DATA_PTRS                     ((DM_SM_ENCRYPT_DATA_LEN + DM_SM_ENCRYPT_DATA_PER_PTR - 1)  / DM_SM_ENCRYPT_DATA_PER_PTR)

/* Flags */
#define DM_SM_ENCRYPT_DATA_FLAGS_ENCRYPT            (1<<0)
#define DM_SM_ENCRYPT_DATA_FLAGS_DECRYPT            (1<<1)
#define DM_SM_ENCRYPT_DATA_FLAGS_RANDOMIZER_PRESENT (1<<2)

/* DM SM ENCRYPT status */
#define DM_SM_ENCRYPT_STATUS_SUCCESS                (0) /* Success status */
/* New encrypt request initiated when one such is in progress */
#define DM_SM_ENCRYPT_STATUS_BUSY                   (1)
#define DM_SM_ENCRYPT_STATUS_INVALID_PARAM          (2) /* Invalid parameters in REQ */
/* Length of the data is beyond allowed limit DM_SM_ENCRYPT_DATA_LEN */
#define DM_SM_ENCRYPT_STATUS_PACKET_TOO_LONG        (3)
#define DM_SM_ENCRYPT_STATUS_INVALID_MIC            (4) /* Mic value is incorrect */
#define DM_SM_ENCRYPT_STATUS_HCI_AES_FAILURE        (5) /* HCI AES encrypt failed */
#define DM_SM_ENCRYPT_STATUS_GENERIC_FAIL           (6) /* General Failure status */

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      This API allows application to encrypt or decrypt the data using
 *      AES-CCM algorithm.
 *
 *      Each index of data[] shall hold maximum of HCI_VAR_ARG_POOL_SIZE
 *      number of octets.
 *
 *      For flags set as DM_SM_ENCRYPT_DATA_FLAGS_ENCRYPT,
 *      a) The randomizer value shall be generated by stack unless application
 *      sets DM_SM_ENCRYPT_DATA_FLAGS_RANDOMIZER_PRESENT and passes the
 *      randomizer value.
 *      b) Mic field shall be ignored.
 *
 *      For flags set as DM_SM_ENCRYPT_DATA_FLAGS_DECRYPT, the application shall
 *      have to provide the randomizer and mic field. For decrypt randomizer
 *      flag is not required to be set.
 *
 *      Note:
 *      Ownership of pointers in data[] present is transferred to
 *      the stack and will be freed by the stack.
 *      Caller should not free the data[].
 *
 * RETURNS
 * None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t   type;                               /* DM_SM_ENCRYPT_DATA_REQ */
    phandle_t   phandle;                            /* Destination phandle */
    uint16_t    flags;                              /* Flags refer DM_SM_ENCRYPT_DATA_FLAGS_* */
    uint8_t     session_key[DM_SM_ENCRYPT_KEY_LEN]; /* Key for encryption/decryption */
    uint8_t     iv[DM_SM_ENCRYPT_IV_LEN];           /* Initialization vector */
    uint8_t     randomizer[DM_SM_ENCRYPT_RAND_LEN]; /* Randomizer value */
    uint8_t     mic[DM_SM_ENCRYPT_MIC_LEN];         /* Mic value */
    uint16_t    data_len;                           /* Total length of the data field */
    uint8_t     *data[DM_SM_ENCRYPT_DATA_PTRS];     /* Array of data pointers */
} DM_SM_ENCRYPT_DATA_REQ_T;

/*-------------------------------------------------------------
  Upstream DM Crypto primitives
 ---------------------------------------------------------------*/

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      DM sends this primitive to application to notify the completion of 
 *      DM_CRYPTO_GENERATE_PUBLIC_PRIVATE_KEY_REQ (ECC public-private key
 *      generation operation). The status field indicates the success or
 *      failure of the ECC key generation.
 *
 *      For ECC-192 a "public_key" (UINT16 representation) generated as following:
 *      M(15)--------------------------------------------------- L(ed)
 *      |1520|7009|9844|21a6|586f|9fc3|fe7e|4329|d280|9ea5|1125|f8ed|<-- Public key X
 *      M(b0)--------------------------------------------------- L(25)
 *      |b09d|42b8|1bc5|bd00|9f79|e4b5|9dbb|aa85|7fca|856f|b9f7|ea25|<-- Public key Y
 *      will be presented in "remote_public_key" array as below:
 *      remote_public_key[0] = 0xf8ed;
 *      remote_public_key[1] = 0x1125;
 *              ....
 *              ....
 *      remote_public_key[11] = 0x1520;
 *      remote_public_key[12] = 0xea25;
 *      remote_public_key[13] = 0xb9f7;
 *              ....
 *              ....
 *      remote_public_key[23] = 0xb09d;
 *
 *      For ECC-192 a "private_key" (UINT16 representation) generated as following:
 *      M(1e) --------------------------------------------------L(6d)
 *      |1e63|6ca7|90b5|0f68|f15d|8dbe|8624|4e30|9211|d635|de00|e16d|
 *      will be presented in "private_key" array as below:
 *      private_key[0] = 0xe16d;
 *      private_key[1] = 0xde00;
 *              ....
 *              ....
 *      private_key[11] = 0x1e63;
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;                                       /* DM_CRYPTO_GENERATE_PUBLIC_PRIVATE_KEY_CFM */
    phandle_t       phandle;                                    /* destination phandle */
    uint8_t         key_type;                                   /* DM_CRYPTO_ECC_P192/DM_CRYPTO_ECC_P256 */
    context_t       context;                                    /* Opaque context returned from REQ */
    uint8_t         status;                                     /* Generation success or failed */
    uint16_t        public_key[DM_CRYPTO_PUBLIC_KEY_SIZE];      /* Public key, zero if status is failure */
    uint16_t        private_key[DM_CRYPTO_PRIVATE_KEY_SIZE];    /* Private key, zero if status is failure */
} DM_CRYPTO_GENERATE_PUBLIC_PRIVATE_KEY_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      DM sends this primitive to application to notify the completion of 
 *      DM_CRYPTO_GENERATE_SHARED_SECRET_KEY_REQ (ECDH_key generation 
 *      operation). The status field indicates the success or failure of
 *      ECDH_key generation.
 *
 *      For ECC-192 a "shared_secret_key" generated as following:
 *      M(fb)---------------------------------------------------L(46)
 *      |fb3b|a201|2c7e|6246|6e48|6e22|9290|175b|4afe|bc13|fdcc|ee46|
 *      will be presented in "shared_secret_key" array as below:
 *      shared_secret_key[0] = 0xee46;
 *      shared_secret_key[1] = 0xfdcc;
 *              ....
 *              ....
 *      shared_secret_key[11] = 0xfb3b;
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t   type;                                           /* DM_CRYPTO_GENERATE_SHARED_SECRET_KEY_CFM */
    phandle_t   phandle;                                        /* destination phandle */
    uint8_t     key_type;                                       /* DM_CRYPTO_ECC_P192/DM_CRYPTO_ECC_P256 */
    context_t   context;                                        /* Opaque context returned from REQ */
    uint8_t     status;                                         /* Generation success or failed */
    uint16_t    shared_secret_key[DM_CRYPTO_SECRET_KEY_SIZE];   /* Shared secret key(dhkey), zero if status is not success */
} DM_CRYPTO_GENERATE_SHARED_SECRET_KEY_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      DM sends this primitive to application to notify the completion of 
 *      DM_CRYPTO_ENCRYPT_REQ_T (AES_128 encryption).
 *      The status field indicates the success or failure of the AES_128
 *      encryption.
 *
 *      An "encrypted_data" generated as following:
 *      M(69)-------------------------------L(5a)
 *      |69c4|e0d8|6a7b|0430|d8cd|b780|70b4|c55a|
 *      will be presented in "encrypted_data" array as below:
 *      encrypted_data[0] = 0xc55a;
 *      encrypted_data[1] = 0x70b4;
 *              ....
 *              ....
 *      encrypted_data[11] = 0x69c4;
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;                                       /* DM_CRYPTO_ENCRYPT_CFM */
    phandle_t       phandle;                                    /* Destination phandle */
    uint8_t         flags;                                      /* reserved */
    context_t       context;                                    /* Opaque context returned from REQ */
    uint8_t         status;                                     /* Generation success or failed */
    uint16_t        encrypted_data[DM_CRYPTO_AES_DATA_SIZE];    /* Encrypted data */
} DM_CRYPTO_ENCRYPT_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      DM sends this primitive to application to notify the completion of 
 *      DM_CRYPTO_HASH_REQ_T (SHA_256 hash generation).
 *      The status field indicates the success or failure of the SHA_256 hash
 *      generation.
 *
 *  Sample data:
 *
 *  Input value :
 *      The even length application data with a UINT16 representation:
 *      M(61)-------------------------------L(70)
 *      |6162|6364|6566|6768|696a|6b6c|6d6e|6f70|
 *      has to be filled in "data" array in the following format:
 *      data[0] = 0x6f70;
 *      data[1] = 0x6d6e;
 *          ....
 *          ....
 *      data[7] = 0x6162;
 *
 *  Hashed result:
 *      A "hash" value generated as following:
 *      M(f3)-----------------------------------------------------------------------L(cf)
 *      |f39d|ac6c|baba|535e|2c20|7cd0|cd8f|1549|7422|3c84|8f72|7f98|b356|4cea|569b|41cf|
 *      will be presented in "hash" array as below:
 *      hash[0] = 0x9df3;
 *      hash[1] = 0x6cac;
 *          ....
 *          ....
 *      hash[15] = 0xcf41;
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;                               /* DM_CRYPTO_HASH_CFM */
    phandle_t       phandle;                            /* Destination phandle */
    uint8_t         operation;                          /* Operation type from request */
    uint8_t         flags;                              /* Reserved */
    context_t       context;                            /* Opaque context returned from REQ */
    uint8_t         status;                             /* Generation succeeded or failed */
    uint16_t        hash[DM_CRYPTO_SHA_HASH_SIZE];      /* Hash of the supplied data */
} DM_CRYPTO_HASH_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      DM sends this primitive to application to notify the completion of
 *      DM_CRYPTO_DECRYPT_REQ_T (AES_128 decryption).
 *      The status field indicates the success or failure of the AES_128
 *      decryption.
 *
 *      The "decrypted_data" generated as following:
 *      M(00)-------------------------------L(ff)
 *      |0011|2233|4455|6677|8899|aabb|ccdd|eeff|
 *      will be presented in "decrypted_data" array as below:
 *      decrypted_data[0] = 0xeeff;
 *      decrypted_data[1] = 0xccdd;
 *      ....
 *      ....
 *      decrypted_data[11] = 0x0011;
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t        type;                                    /* DM_CRYPTO_DECRYPT_CFM */
    phandle_t        phandle;                                 /* Destination phandle */
    context_t        context;                                 /* Opaque context returned from REQ */
    uint8_t          flags;                                   /* Reserved */
    uint8_t          status;                                  /* Generation success or failed */
    uint16_t         decrypted_data[DM_CRYPTO_AES_DATA_SIZE]; /* Decrypted data; Plain text */
} DM_CRYPTO_DECRYPT_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      DM sends this primitive to application to notify the completion of
 *      DM_CRYPTO_AES_CTR_REQ_T (AES_128 CTR encryption/decryption).
 *      The status field indicates the success or failure of the AES_128 CTR
 *      encryption/decryption.
 *
 *      The data with a UINT16 representation:
 *      M(ee)-------------------------------L(c6)
 *      |ee4a|2483|7380|52e4|4e9b|2a14|5e5d|dfaa|44b9|e553|6af4|38e1|e5c6
 *      will be presented in "data" array as below:
 *      data[0] = 0xe5c6;
 *      data[1] = 0x38e1;
 *      ....
 *      ....
 *      data[12] = 0xee4a;
 *
 *      data_len: Number of uint16 words.
 *      The MAX output data returns is 32 uint16 (64 bytes).
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t          type;              /* DM_CRYPTO_AES_CTR_CFM */
    phandle_t          phandle;           /* Destination phandle */
    context_t          context;           /* Opaque context received in REQ */
    dm_crypto_flags_t  flags;             /* See crypto flags */
    uint8_t            status;            /* Generation success or failed */
    /* Number of uint16 output data (Plain or cipher text) length; Max 32 */
    uint16_t           data_len;
    uint16_t           *data;             /* Output data */
} DM_CRYPTO_AES_CTR_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      DM sends this primitive to application to notify the completion of
 *      DM_SM_SIRK_OPERATION_REQ.
 *
 *      'sirk_key' will contain the encrypted/decrypted SIRK(Set Identity Resolving 
 *      Key) if the status is DM_SM_SIRK_OPERATION_STATUS_SUCCESS.
 *
 *  Sample data:
 *
 *      For the LTK,
 *      M(67)---------------------------L(d9)
 *      |676e1b9b d448696f 061ec622 3ce5ced9|

 *      The sirk_key returned with a UINT8 representation would be,
 *      M(17)---------------------------L(46)
 *      |170a3835 e13524a0 7e2562d5 f25fd346|
 *      will be presented in "sirk_key" array as below:
 *      sirk_key[0] = 0x17;
 *      sirk_key[1] = 0x0a;
 *      sirk_key[2] = 0x38;
 *      sirk_key[3] = 0x35;
 *      ....
 *      ....
 *      sirk_key[14] = 0xd3;
 *      sirk_key[15] = 0x46;
 *
 *----------------------------------------------------------------------------*/

/* SIRK operation status */
#define DM_SM_SIRK_OPERATION_STATUS_SUCCESS                     0
#define DM_SM_SIRK_OPERATION_STATUS_FAILURE                     1

typedef struct
{
    dm_prim_t       type;                               /* DM_SM_SIRK_OPERATION_CFM */
    phandle_t       phandle;                            /* Destination phandle */
    context_t       context;                            /* Opaque context returned from REQ */
    TP_BD_ADDR_T    tp_addrt;                           /* Transport type would always be LE.
                                                           However fat BD addr is used since it
                                                           is with most informative and therefore
                                                           good to have on interface. */
    uint8_t         status;                             /* Generation success or failed */
    uint8_t         sirk_key[DM_SM_SIRK_KEY_SIZE];      /* Hashed Data */
} DM_SM_SIRK_OPERATION_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      DM sends this primitive to application to notify the completion of
 *      DM_SM_ENCRYPT_DATA_REQ_T.
 *      The status field indicates the success or failure of the operation
 *      set in flags during DM_SM_ENCRYPT_DATA_REQ_T.
 *
 *      Data will be pointed to the encrypt data or plain text in case of
 *      decryption.
 *
 *      Note:
 *      Ownership of pointers in data[] present is transferred to
 *      the application and shall be freed by the application.
 *
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t   type;                               /* DM_SM_ENCRYPT_DATA_CFM */
    phandle_t   phandle;                            /* Destination phandle */
    uint8_t     status;                             /* See DM_SM_ENCRYPT_STATUS_* */
    uint16_t    flags;                              /* Flags from request */
    uint8_t     randomizer[DM_SM_ENCRYPT_RAND_LEN]; /* Randomizer value */
    uint8_t     mic[DM_SM_ENCRYPT_MIC_LEN];         /* Mic values */
    uint16_t    data_len;                           /* Total length of the data field */
    uint8_t     *data[DM_SM_ENCRYPT_DATA_PTRS];     /* Encrypted or decrypted data */
} DM_SM_ENCRYPT_DATA_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *      
 *      DM_ULP_ENABLE_ZERO_SLAVE_LATENCY_REQ_T.
 *      Enable/Disable the local device to have zero slave latency for the LE
 *      link provided by the tp_addrt.
 *      This command put the LE slave link to zero latency when
 *      'zero_latency' is set to TRUE. When this input is FALSE, the command
 *      restores the slave latency provided by LE master.
 *
 *      Note that this command is applicable for LE slave only.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t    type;                /* DM_ULP_ENABLE_ZERO_SLAVE_LATENCY_REQ */
    phandle_t    phandle;             /* Destination phandle */
    TP_BD_ADDR_T tp_addrt;            /* Transport type would always be LE.
                                         However fat BD addr is used since it
                                         is with most informative and therefore
                                         good to have on interface. */
    bool_t       zero_latency;        /* Enable/disable zero LE slave latency */
} DM_ULP_ENABLE_ZERO_SLAVE_LATENCY_REQ_T;



/*----------------------------------------------------------------------------*
 * PURPOSE
 *      
 *      DM_ULP_ENABLE_ZERO_SLAVE_LATENCY_CFM_T.
 *      This confirmation confirms if the LE slave link is put to zero latency
 *      successfully or not.
 *
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t    type;                /* DM_ULP_ENABLE_ZERO_SLAVE_LATENCY_CFM */
    phandle_t    phandle;             /* Destination phandle */
    TP_BD_ADDR_T tp_addrt;            /* Transport type would always be LE.
                                         However fat BD addr is used since it
                                         is with most informative and therefore
                                         good to have on interface. */
    bool_t       zero_latency;        /* Request was sent to Enable/disable zero
                                         LE slave latency */
    hci_error_t  status;              /* Success or failure - See Note1 */
} DM_ULP_ENABLE_ZERO_SLAVE_LATENCY_CFM_T;


/* Physical rate */
typedef uint8_t phy_rate_t;

/* Following are the valid phy_rate_t values that can be supplied to 
 * the downstream DM_ULP_PHY APIs based on application's PHY preferences 
 * for a connection or as default preference*/
 
#define DM_ULP_PHY_RATE_MIN     ((uint8_t) 0x00)
#define DM_ULP_PHY_RATE_125K    ((uint8_t) 0x01)    /* Coded PHY, S=8 */
#define DM_ULP_PHY_RATE_500K    ((uint8_t) 0x02)    /* Coded PHY, S=2 */
#define DM_ULP_PHY_RATE_1M      ((uint8_t) 0x03)    /* Uncoded PHY */
#define DM_ULP_PHY_RATE_2M      ((uint8_t) 0x04)    /* Uncoded PHY */
#define DM_ULP_PHY_RATE_QHS     ((uint8_t) 0x05)    /* QHS PHY */
#define DM_ULP_PHY_RATE_MAX     ((uint8_t) 0xff)

/* Physical type */
typedef uint8_t phy_type_t;

/* Following are the valid phy_type_t values that are used to indicate
 * PHY type of a link.
 */
#define DM_ULP_PHY_TYPE_1M      ((phy_type_t) 0x01)    /* Uncoded PHY */
#define DM_ULP_PHY_TYPE_2M      ((phy_type_t) 0x02)    /* Uncoded PHY */
#define DM_ULP_PHY_TYPE_CODED   ((phy_type_t) 0x03)    /* Coded PHY */
#define DM_ULP_PHY_TYPE_QHS     ((phy_type_t) 0x80)    /* QHS PHY */

/* Additional physical preferences, reserved for now shall be set to zero */
typedef uint8_t phy_pref_t;

/* QHS-rate physical preferences values for Tx */
#define DM_ULP_PHY_RATE_QHS_UNSPECIFIED     ((phy_pref_t) 0x00)
#define DM_ULP_PHY_RATE_QHS_TX_QHS2         ((phy_pref_t) 0x10)
#define DM_ULP_PHY_RATE_QHS_TX_QHS3         ((phy_pref_t) 0x20)
#define DM_ULP_PHY_RATE_QHS_TX_QHS4         ((phy_pref_t) 0x30)
#define DM_ULP_PHY_RATE_QHS_TX_QHS5         ((phy_pref_t) 0x40)
#define DM_ULP_PHY_RATE_QHS_TX_QHS6         ((phy_pref_t) 0x50)
/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This API allows applications to provide PHY preferences for a given 
 * connection on LE transport. Preferences for physical rate can be set for 
 * both transmission and receiving side, this would help the controller to
 * decide upon an appropriate PHY. Bluestack would then indicate the actual PHY
 * controller selected using DM_ULP_SET_PHY_CFM. It has to be noted that 
 * setting of PHY preferences doesn't guarantee the same PHY will be used for 
 * the connection. 

 * Applications should carefully choose PHY preferences depending on robustness 
 * or higher data rate requirements. In case there is no PHY preference on 
 * either direction of communication (rx or tx), minimum and maximum preferences
 * shall be set to DM_ULP_PHY_RATE_MIN and DM_ULP_PHY_RATE_MAX respectively. 
 *
 * Example usage of the API,
 * a. If user prefers to use either 1M or 2M PHY to receive data and 
 *    1M PHY to transmit data then following values should be set.
 *     min_tx = DM_ULP_PHY_RATE_1M
 *     max_tx = DM_ULP_PHY_RATE_1M
 *     min_rx = DM_ULP_PHY_RATE_1M
 *     max_rx = DM_ULP_PHY_RATE_2M
 *    In this case controller may initiate LL procedure to request PHY update 
 *    to use 2M PHY for rx.
 * 
 * b. If user prefers to use coded PHY s=8 for transmission and if it has
 *    no preference for receiving side then following values should be set.
 *     min_tx = DM_ULP_PHY_RATE_125K
 *     max_tx = DM_ULP_PHY_RATE_125K
 *     min_rx = DM_ULP_PHY_RATE_MIN
 *     max_rx = DM_ULP_PHY_RATE_MAX
 *
 * Note: Do not use DM_ULP_PHY_RATE_MIN or DM_ULP_PHY_RATE_MAX with other
 *      specific range values.
 *   Example,
 *     min_tx = DM_ULP_PHY_RATE_MIN
 *     max_tx = DM_ULP_PHY_RATE_2M
 *     min_rx = DM_ULP_PHY_RATE_1M
 *     max_rx = DM_ULP_PHY_RATE_MAX
 *
 * Note: 
 * 1. Local controller or remote device may autonomously trigger PHY update 
 *    because of various reasons, during such events DM_ULP_PHY_UPDATE_IND will
 *    be sent to the applications to notify the change.
 * 2. Users can set PHY preference values only in contiguous range, preferences 
 *    such as 125K PHY and 2M PHY (excluding 512K,1M) is considered as 
 *    odd choice hence it is not supported in this API.
 *
 * RETURNS
 *     DM_ULP_SET_PHY_CFM_T
 *----------------------------------------------------------------------------*/
 typedef struct
{
    dm_prim_t       type;          /* DM_ULP_SET_PHY_REQ */
    phandle_t       phandle;       /* destination phandle */
    TP_BD_ADDR_T    tp_addrt;      /* transport Bluetooth device address */
    phy_rate_t      min_tx;        /* Minimum preferred tx rate */
    phy_rate_t      max_tx;        /* Maximum preferred tx rate */
    phy_rate_t      min_rx;        /* Minimum preferred rx rate */
    phy_rate_t      max_rx;        /* Maximum preferred rx rate */
    phy_pref_t      flags;         /* Flags for additional preference.
                                      Shall be one of HCI_ULP_PHY_OPTIONS_xxx 
                                      in hci.h */
} DM_ULP_SET_PHY_REQ_T;


/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This event will notify the status of the DM_ULP_SET_PHY_REQ command 
 * given by the application. Status value other than zero is considered to be 
 * failure. Status being success doesn't necessarily  mean all the preferred 
 * PHY choices has taken into effect, rather it indicates either rx or tx PHY 
 * or both has been updated.
 *
 * Note: Type of coded PHY (s=2 or s=8) is not indicated to application.
 * Type of PHY will indicate whether the link is on 1M, 2M or Coded PHY type,
 * ref : phy_type_t.
 *
 * RETURNS
 *     None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;          /* DM_ULP_SET_PHY_CFM */
    phandle_t       phandle;       /* destination phandle */
    TP_BD_ADDR_T    tp_addrt;      /* transport Bluetooth device address */
    phy_type_t      tx_phy_type;   /* current tx PHY type of the connection */
    phy_type_t      rx_phy_type;   /* current rx PHY type of the connection */
    hci_return_t    status;        /* anything other than zero is failure */
} DM_ULP_SET_PHY_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This event would be sent to application to notify the change in PHY of a 
 * connection. Local controller may choose to update PHY autonomously
 * for various reasons, including remote device requesting for an update.
 *
 * Note: Type of coded PHY (s=2 or s=8) is not indicated to application.
 * Type of PHY will indicate whether the link is on 1M, 2M or Coded PHY type,
 * ref : phy_type_t.
 * 
 * RETURNS
 *     None
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t       type;         /* DM_ULP_PHY_UPDATE_IND */
    phandle_t       phandle;      /* destination phandle */
    TP_BD_ADDR_T    tp_addrt;     /* transport Bluetooth device address */
    phy_type_t      tx_phy_type;  /* updated tx PHY type of the connection */
    phy_type_t      rx_phy_type;  /* updated rx PHY type of the connection */
} DM_ULP_PHY_UPDATE_IND_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This API allows applications to provide PHY preferences for all upcoming 
 * connections after this request is processed successfully. Usage of this API 
 * is same as DM_ULP_SET_PHY_REQ, but the preference would be applied to all 
 * subsequent connections.
 *
 * RETURNS
 *     DM_ULP_SET_DEFAULT_PHY_CFM_T
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t       type;          /* DM_ULP_SET_DEFAULT_PHY_REQ */
    phandle_t       phandle;       /* destination phandle */
    phy_rate_t      min_tx;        /* Minimum preferred tx rate */
    phy_rate_t      max_tx;        /* Maximum preferred tx rate */
    phy_rate_t      min_rx;        /* Minimum preferred rx rate */
    phy_rate_t      max_rx;        /* Maximum preferred rx rate */
    phy_pref_t      flags;         /* Flags for additional preference,
                                      reserved for now. Shall be set to zero */
} DM_ULP_SET_DEFAULT_PHY_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This event will notify the status of the DM_ULP_SET_DEFAULT_PHY_REQ command
 * given by the application. Status value other than zero is considered to be
 * failure.
 *
 * RETURNS
 *     None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;          /* DM_ULP_SET_DEFAULT_PHY_CFM */
    phandle_t       phandle;       /* destination phandle */
    hci_return_t    status;        /* status of set default PHY */
} DM_ULP_SET_DEFAULT_PHY_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This API allows applications to read current transmitter PHY and receiver
 * PHY for a given connection on LE transport.
 *
 * RETURNS
 *     DM_ULP_READ_PHY_CFM_T
 *----------------------------------------------------------------------------*/
 typedef struct
{
    dm_prim_t       type;          /* DM_ULP_READ_PHY_REQ */
    phandle_t       phandle;       /* destination phandle */
    TP_BD_ADDR_T    tp_addrt;      /* transport Bluetooth device address */
} DM_ULP_READ_PHY_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This event will notify the status of the DM_ULP_READ_PHY_REQ command 
 * given by the application. Status value other than zero is considered to be 
 * failure.
 *
 * Note: Type of coded PHY (s=2 or s=8) is not indicated to application.
 * Type of PHY will indicate whether the link is on 1M, 2M or Coded PHY type,
 * ref : phy_type_t.
 *
 * RETURNS
 *     None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;          /* DM_ULP_SET_PHY_CFM */
    phandle_t       phandle;       /* destination phandle */
    TP_BD_ADDR_T    tp_addrt;      /* transport Bluetooth device address */
    phy_type_t      tx_phy_type;   /* current tx PHY type of the connection */
    phy_type_t      rx_phy_type;   /* current rx PHY type of the connection */
    hci_return_t    status;        /* anything other than zero is failure */
} DM_ULP_READ_PHY_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This API allows applications to read the current and maximum transmit power
 * levels of the local Controller on the specified connection.
 *
 * RETURNS
 *     DM_ULP_ENHANCED_READ_TRANSMIT_POWER_LEVEL_CFM_T
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t type;        /* DM_ULP_ENHANCED_READ_TRANSMIT_POWER_LEVEL_REQ_T */
    TP_BD_ADDR_T tp_addrt; /* transport Bluetooth device address */
    uint8_t phy;           /* type of phy, will indicate whether the 
                              link is on 1M, 2M or Coded PHY type*/
} DM_ULP_ENHANCED_READ_TRANSMIT_POWER_LEVEL_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This event will notify the status of the DM_ULP_ENHANCED_READ_TRANSMIT_POWER_LEVEL_REQ
 * command given by the application. Status value other than zero is considered
 * to be failure.
 *
 * RETURNS
 *     None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t type;        /* DM_ULP_ENHANCED_READ_TRANSMIT_POWER_LEVEL_CFM_T */
    phandle_t phandle;     /* destination phandle */
    TP_BD_ADDR_T tp_addrt; /* transport Bluetooth device address */
    uint8_t phy;           /* type of phy, will indicate whether the 
                              link is on 1M, 2M or Coded PHY type*/
    int8_t current_tx_pwr_level;
                           /* current transmit power lever */
    int8_t max_tx_pwr_level;
                           /* max transmit power lever */
    hci_return_t status;   /* anything other than zero is failure */
} DM_ULP_ENHANCED_READ_TRANSMIT_POWER_LEVEL_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This API allows applications to read the transmit power level used by the 
 * remote Controller on the specified connection
 *
 * RETURNS
 *     DM_ULP_READ_REMOTE_TRANSMIT_POWER_LEVEL_CFM_T
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t type;        /* DM_ULP_READ_REMOTE_TRANSMIT_POWER_LEVEL_REQ */
    TP_BD_ADDR_T tp_addrt; /* transport Bluetooth device address */
    uint8_t phy;           /* type of phy, will indicate whether the 
                                   link is on 1M, 2M or Coded PHY type*/
} DM_ULP_READ_REMOTE_TRANSMIT_POWER_LEVEL_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 * 
 * This event will notify the status of the DM_ULP_READ_REMOTE_TRANSMIT_POWER_LEVEL_REQ
 * command given by the application. Status value other than zero is considered
 * to be failure. This prim will be send once a HCI_LE_Transmit_Power_Reporting 
 * event is generated.
 *
 * RETURNS
 *     None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t type;        /* DM_ULP_READ_REMOTE_TRANSMIT_POWER_LEVEL_CFM_T */
    phandle_t phandle;     /* destination phandle */
    TP_BD_ADDR_T tp_addrt; /* transport Bluetooth device address */
    uint8_t reason;        /* Reason for power change */
    uint8_t phy;           /* type of phy, will indicate whether the 
                              link is on 1M, 2M or Coded PHY type*/
    int8_t tx_pwr_level;   /* Transmit power level */
    uint8_t tx_pwr_level_flag;
                           /* Transmit power level at Min/Max */
    int8_t delta;          /* Change in transmit power level 
                              (zero means unchanged) */
    hci_return_t status;   /* anything other than zero is failure */
} DM_ULP_READ_REMOTE_TRANSMIT_POWER_LEVEL_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This prim will be send once an periodic HCI_LE_Transmit_Power_Reporting 
 * event is generated.
 *
 * RETURNS
 *     None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t type;        /* DM_ULP_TRANSMIT_POWER_REPORTING_IND_T */
    phandle_t phandle;     /* destination phandle */
    TP_BD_ADDR_T tp_addrt; /* transport Bluetooth device address */
    uint8_t reason;        /* Reason for power change */
    uint8_t phy;           /* type of phy, will indicate whether the 
                                           link is on 1M, 2M or Coded PHY type*/
    int8_t tx_pwr_level;   /* Transmit power level */
    uint8_t tx_pwr_level_flag;
                           /* Transmit power level at Min/Max */
    int8_t delta;          /* Change in transmit power level 
                              (zero means unchanged) */
} DM_ULP_TRANSMIT_POWER_REPORTING_IND_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This API allows applications to set the path loss threshold reporting
 * parameters for the specified connection
 *
 * RETURNS
 *     DM_ULP_SET_PATH_LOSS_REPORTING_PARAMETERS_CFM_T
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t       type;           /* DM_ULP_SET_PATH_LOSS_REPORTING_PARAMETERS_REQ_T */
    TP_BD_ADDR_T    tp_addrt;       /* transport Bluetooth device address */
    int8_t          high_threshold; /* High threshold for path loss */
    int8_t          high_hysteresis;/* Hysteresis value for the high threshold */
    int8_t          low_threshold;  /* Low threshold for path loss */
    int8_t          low_hysteresis; /* Hysteresis value for the low threshold */
    uint16_t        min_time_spent; /* Minimum time in number of connection events 
                                       to be observed once the path crosses the 
                                       threshold before an event is generated */
} DM_ULP_SET_PATH_LOSS_REPORTING_PARAMETERS_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This event will notify the status of the DM_ULP_SET_PATH_LOSS_REPORTING_PARAMETERS_REQ_T
 * command given by the application. Status value other than zero is considered
 * to be failure.
 * 
 * RETURNS
 *     None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;          /* DM_ULP_SET_PATH_LOSS_REPORTING_PARAMETERS_CFM_T */
    phandle_t       phandle;       /* destination phandle */
    TP_BD_ADDR_T    tp_addrt;      /* transport Bluetooth device address */
    hci_return_t    status;        /* anything other than zero is failure */
} DM_ULP_SET_PATH_LOSS_REPORTING_PARAMETERS_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This API allows applications to enable or disable path loss reporting for 
 * the specified connection
 *
 * RETURNS
 *     DM_ULP_SET_PATH_LOSS_REPORTING_ENABLE_CFM_T
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t       type;          /* DM_ULP_SET_PATH_LOSS_REPORTING_ENABLE_REQ */
    TP_BD_ADDR_T    tp_addrt;      /* transport Bluetooth device address */
    uint8_t         enable;
}DM_ULP_SET_PATH_LOSS_REPORTING_ENABLE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This event will notify the status of the DM_ULP_SET_PATH_LOSS_REPORTING_ENABLE_REQ_T
 * command given by the application. Status value other than zero is considered
 * to be failure.
 *
 * RETURNS
 *     None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;          /* DM_ULP_SET_PATH_LOSS_REPORTING_ENABLE_CFM_T */
    phandle_t       phandle;       /* destination phandle */
    TP_BD_ADDR_T    tp_addrt;      /* transport Bluetooth device address */
    hci_return_t    status;        /* anything other than zero is failure */
} DM_ULP_SET_PATH_LOSS_REPORTING_ENABLE_CFM_T;


/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 *  This API allows applications to enable or disable the reporting to the local
 *  Host of transmit power level changes in the local and remote Controllers for 
 * the specified connection
 *
 * RETURNS
 *     DM_ULP_SET_TRANSMIT_POWER_REPORTING_ENABLE_CFM_T
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t       type;          /* DM_ULP_SET_TRANSMIT_POWER_REPORTING_ENABLE_REQ */
    TP_BD_ADDR_T    tp_addrt;      /* transport Bluetooth device address */
    uint8_t         local_enable;  /* disable or enable local transmit power report */
    uint8_t         remote_enable; /* disable or enable remote transmit power report */
}DM_ULP_SET_TRANSMIT_POWER_REPORTING_ENABLE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This event will notify the status of the DM_ULP_SET_TRANSMIT_POWER_REPORTING_ENABLE_REQ_T
 * command given by the application. Status value other than zero is considered
 * to be ailure.
 *
 * RETURNS
 *     None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;          /* DM_ULP_SET_TRANSMIT_POWER_REPORTING_ENABLE_CFM_T */
    phandle_t       phandle;       /* destination phandle */
    TP_BD_ADDR_T    tp_addrt;      /* transport Bluetooth device address */
    hci_return_t    status;        /* anything other than zero is failure */
} DM_ULP_SET_TRANSMIT_POWER_REPORTING_ENABLE_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This prim will be send once an periodic HCI_LE_Path_Loss_Threshold 
 * event is generated.
 *
 * RETURNS
 *     None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;        /* DM_ULP_PATH_LOSS_THRESHOLD_IND */
    phandle_t       phandle;     /* destination phandle */
    TP_BD_ADDR_T    tp_addrt;    /* transport Bluetooth device address */
    uint8_t         curr_path_loss; 
                                 /* Indicates the current path loss value as
                                    calculated by the Controller */
    uint8_t         zone_entered;/* Parameter indicates which zone was entered */
} DM_ULP_PATH_LOSS_THRESHOLD_IND_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Supplies information about what is supported with regards advertising extensions
 * (AE):
 *
 *    1) What public bluestack AE APIs are available.
 *       (e.g. Legacy advertising/scanning, extended advertising/scanning,
 *             periodic advertising/scanning, PAST sender and PAST recipient)
 *    2) Max advertising sets that the application can register
 *    3) Advertising sets registered by stack
 *    4) Max number of periodic trains that can be looked for when trying to sync to a
 *       periodic train
 *    5) Supported LE phys (e.g. 1M, 2M and Coded)
 *    6) Max LE advertising data (e.g. 0 to 1650 octets)
 *
 * RETURNS
 *     DM_ULP_GET_ADV_SCAN_CAPABILITIES_CFM_T
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t       type;             /* DM_ULP_GET_ADV_SCAN_CAPABILITIES_REQ */
} DM_ULP_GET_ADV_SCAN_CAPABILITIES_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_GET_ADV_SCAN_CAPABILITIES_CFM
 *---------------------------------------------------------------------------*/

/* The available_api bit defines */
#define DM_ULP_ADV_SCAN_API_LEGACY 1            /* LE legacy advertising/scanning API */
#define DM_ULP_ADV_SCAN_API_EXTENDED 2        /* LE extended advertising/scanning API */
#define DM_ULP_ADV_SCAN_API_PERIODIC 4        /* LE periodic advertising/scanning API */
#define DM_ULP_ADV_SCAN_API_PAST_SENDER 8                       /* LE PAST sender API */
#define DM_ULP_ADV_SCAN_API_PERIODIC_RECIPIENT 16            /* LE PAST recipient API */
#define DM_ULP_ADV_SCAN_API_PERIODIC_ADI 32   /* LE periodic advertising/scanning API
                                            supports Periodic Advertising ADI feature */

/* The max length of extended and periodic advertising data */
#define DM_ULP_MAX_POTENTIAL_ADV_DATA_LEN 1650

typedef struct
{
    dm_prim_t       type;          /* DM_ULP_GET_ADV_SCAN_CAPABILITIES_CFM */
    phandle_t       phandle;       /* destination phandle */
    hci_return_t    status;        /* Success or failure - See Note1 */
    uint8_t         available_api; /* Refer to 1 above and available_api bit defines */
    uint8_t         available_adv_sets;                          /* Refer to 2 above */
    uint8_t         stack_reserved_adv_sets;                     /* Refer to 3 above */
    uint8_t         max_periodic_sync_list_size;                 /* Refer to 4 above */
    uint16_t        supported_phys;                              /* Refer to 5 above */
    uint16_t        max_potential_size_of_tx_adv_data;           /* Refer to 6 above */
    uint16_t        max_potential_size_of_tx_periodic_adv_data;  /* Refer to 6 above */
    uint16_t        max_potential_size_of_rx_adv_data;           /* Refer to 6 above */
    uint16_t        max_potential_size_of_rx_periodic_adv_data;  /* Refer to 6 above */
} DM_ULP_GET_ADV_SCAN_CAPABILITIES_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Used to control if advertiser's RPA changes when advertising data or scan response
 * data is changed. This is configurable on a per advertising set bases.
 *
 * Note: The adv_handle field must be set to ADV_HANDLE_FOR_LEGACY_API if running on a
 *       device that does not support extended advertising. This will allow the
 *       primitive to work with legacy advertising HCI commands.
 *
 * RETURNS
 *     DM_ULP_SET_DATA_RELATED_ADDRESS_CHANGES_CFM_T
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;         /* DM_ULP_EXT_ADV_DATA_RELATED_ADDRESS_CHANGES_REQ */
    uint8_t         adv_handle;   /* Advertising set */
    uint8_t         flags;        /* Reserved always set to 0 */

    /* bits 0-1:
       Says if the advertiser's address will change when using controller based RPA
       generation and data changes:
       0 = No address change
       1 = Address change if advertising data changes
       2 = Address change if scan response data changes
       3 = Address change if advertising or scan response data changes

       bits 2-7:
       Reserved for future use. */
    uint8_t         change_reasons;
} DM_ULP_SET_DATA_RELATED_ADDRESS_CHANGES_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_SET_DATA_RELATED_ADDRESS_CHANGES_CFM
 *---------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_ULP_SET_DATA_RELATED_ADDRESS_CHANGES_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Reports advertising and registered states for all advertising sets supported by a
 * device.
 *
 * RETURNS
 *     DM_ULP_EXT_ADV_SETS_INFO_CFM_T
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t       type;                   /* DM_ULP_EXT_ADV_SETS_INFO_REQ */
} DM_ULP_EXT_ADV_SETS_INFO_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_EXT_ADV_SETS_INFO_CFM
 *---------------------------------------------------------------------------*/

/* This is advertising handle reserved for use by extended advertising when using
   old LE connection/advertising APIs. */
#define ADV_HANDLE_FOR_LEGACY_API ((uint8_t) 0)

/* This advertising handle value is used to say that an adv_handle is invalid. */
#define DM_ULP_EXT_ADV_HANDLE_INVALID ((uint8_t) 255)

/* Max number of advertising sets allowed to be used by application.
   (Including ADV_HANDLE_FOR_LEGACY_API) */
#define DM_ULP_EXT_ADV_MAX_ADV_HANDLES HCI_ULP_MAX_ENABLE_ADV_SETS

/* Max potential number of adv sets in DM_ULP_EXT_ADV_SETS_INFO_CFM and
   DM_ULP_EXT_ADV_MULTI_ENABLE_CFM */
#define DM_ULP_EXT_ADV_MAX_REPORTED_ADV_SETS 11

/*** Bit settings for field flags ***/
/* bit 0      - Is any advertising set advertising? (true if set)
   bit 1 - 15 - Unspecified maybe any value. */
#define DM_ULP_EXT_ADVERTISING_ENABLED_FLAG  ((uint16_t) 0x0001)

/* Masks for field flags */
#define DM_ULP_EXT_ADVERTISING_ENABLED_MASK  ((uint16_t) 0x0001)


typedef struct
{
    uint8_t           registered;  /* Has this adv set been registered */
    uint8_t           advertising; /* Is this adv set advertising */
    uint16_t          info;        /* Reserved for future use */
} DM_EA_SET_INFO_T;

typedef struct
{
    dm_prim_t         type;                   /* DM_ULP_EXT_ADV_SETS_INFO_CFM */
    phandle_t         phandle;                /* Destination phandle */
    uint16_t          flags;                  /* Flag bits specified above */
    uint8_t           num_adv_sets;           /* Number of adv sets below */

    /* Information about advertising sets */
    DM_EA_SET_INFO_T  adv_sets[DM_ULP_EXT_ADV_MAX_REPORTED_ADV_SETS];
} DM_ULP_EXT_ADV_SETS_INFO_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Allows an application to register for use of an advertising set. The
 * application says which advertising set it wishes to register for by setting the
 * field adv_handle to a value in the range 1 to (DM_ULP_EXT_ADV_MAX_ADV_HANDLES - 1).
 *
 * Bluestack sends DM_ULP_EXT_ADV_REGISTER_APP_ADV_SET_CFM as a response to this API.
 *
 * Note: Use DM_ULP_EXT_ADV_SETS_INFO_REQ to work out what advertising sets have
 *       already been registered.
 *
 * RETURNS
 *     DM_ULP_EXT_ADV_REGISTER_APP_ADV_SET_CFM_T
 *----------------------------------------------------------------------------*/
/* If this flag is set,
 * If application has set a valid adv handle, bluestack will look for preferred
 * adv handle, if it doesn't find the preferred handle free, it looks for free
 * adv handle and sends that to application.
 * if application has set the adv handle to DM_ULP_EXT_ADV_HANDLE_INVALID
 * bluestack finds free adv handle and sends that to application.
 *
 * If this flag is not set, 
 * Bluestack will check if preferred adv handle from application is available.
 * If it is available it will send status as success
 * otherwise failure will be reported.
 */
#define DM_ULP_EXT_ADV_REG_SET_ASSIGNED_BY_STACK         (0x0001)

typedef struct
{
    dm_prim_t       type;          /* DM_ULP_EXT_ADV_REGISTER_APP_ADV_SET_REQ */
    uint8_t         adv_handle;    /* 1 to DM_ULP_EXT_ADV_MAX_ADV_HANDLES - 1 */
    uint32_t        flags;         /* See DM_ULP_EXT_ADV_REG_SET_xxx above */
} DM_ULP_EXT_ADV_REGISTER_APP_ADV_SET_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_EXT_ADV_REGISTER_APP_ADV_SET_CFM
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;          /* DM_ULP_EXT_ADV_REGISTER_APP_ADV_SET_CFM */
    phandle_t       phandle;       /* destination phandle */
    uint8_t         status;        /* Success or failure - See Note1 */
    uint8_t         adv_handle;    /* 1 to DM_ULP_EXT_ADV_MAX_ADV_HANDLES - 1 */
} DM_ULP_EXT_ADV_REGISTER_APP_ADV_SET_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Allows an application to unregister use of an advertising set.
 *
 * RETURNS
 *     DM_ULP_EXT_ADV_UNREGISTER_APP_ADV_SET_CFM_T
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t       type;        /* DM_ULP_EXT_ADV_UNREGISTER_APP_ADV_SET_REQ */
    uint8_t         adv_handle;  /* 1 to DM_ULP_EXT_ADV_MAX_ADV_HANDLES - 1   */
} DM_ULP_EXT_ADV_UNREGISTER_APP_ADV_SET_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_EXT_ADV_UNREGISTER_APP_ADV_SET_CFM
 *---------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_ULP_EXT_ADV_UNREGISTER_APP_ADV_SET_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Configure how you wish the advertising set to advertise.  Further info can be found
 * in BLUETOOTH CORE SPECIFICATION Version 5.2: LE Set Extended Advertising Parameters
 * Command. This primitive would usually always follow after a
 * DM_ULP_EXT_ADV_REGISTER_APP_ADV_SET_REQ unless changing existing parameters for an
 * advertising set.
 *
 * Note: Following parameters will be set internally,
 *       Advertising_TX_Power = 0x7F (Host has no preference).
 *       Scan_Request_Notification_Enable = 0x00 (Disabled)
 *
 * RETURNS
 *     DM_ULP_EXT_ADV_SET_PARAMS_CFM_T
 *----------------------------------------------------------------------------*/
#define DM_ULP_EXT_ADV_SID_INVALID 0x100
#define DM_ULP_EXT_ADV_SID_SHARE 0x200
#define DM_ULP_EXT_ADV_SID_ASSIGNED_BY_STACK 0x400

#define DM_ULP_EXT_ADV_FORCE_PEER_ADDR_TYPE_PUBLIC  (0x80)
#define DM_ULP_EXT_ADV_FORCE_PEER_ADDR_TYPE_RANDOM  (0x81)

typedef struct
{
    dm_prim_t       type;          /* DM_ULP_EXT_ADV_SET_PARAMS_REQ */
    uint8_t         adv_handle;    /* 0 to DM_ULP_EXT_ADV_MAX_ADV_HANDLES - 1 */

    /* Refer to BLUETOOTH CORE SPECIFICATION Version 5.2 */
    uint16_t        adv_event_properties;     /* EA adv_event_properties in hci.h */
    uint32_t        primary_adv_interval_min; /* 0x000020 to 0xFFFFFF */
    uint32_t        primary_adv_interval_max; /* 0x000020 to 0xFFFFFF */
    uint8_t         primary_adv_channel_map;  /* Advertising_Channel_Map in hci.h */
    uint8_t         own_addr_type;            /* X_Address_Type in hci.h */
    TYPED_BD_ADDR_T peer_addr;                /* Address of peer device.
                                                 Note: Below values forces controller to set peer address 
                                                 as per peer_addr.type even if there is a valid Peer IRK for that peer.
                                                 peer_addr.type = 0x80 - Force the Controller to use the
                                                                  Public Device Address passed in peer_addr.addr field.
                                                 peer_addr.type = 0x81 - Force the Controller to use the
                                                                  Random Device Address passed in peer_addr.addr field. */
    uint8_t         adv_filter_policy;        /* Advertising_Filter_Policy in hci.h */
    uint16_t        primary_adv_phy;          /* Refer "EA Primary and Secondary advertising
                                                 phys" in hci.h */
    uint8_t         secondary_adv_max_skip;   /* 0 to 0xFF */
    uint16_t        secondary_adv_phy;        /* Refer "EA Primary and Secondary advertising
                                                 phys" in hci.h */

    /* adv_sid can be set to:
       DM_ULP_EXT_ADV_SID_INVALID           - When legacy advertising set to this
       DM_ULP_EXT_ADV_SID_ASSIGNED_BY_STACK - Stack will assign unique value
       0 to 15                              - Application decides unique value
       DM_ULP_EXT_ADV_SID_SHARE + (0 to 15) - More than 1 advertising set can have this
                                              value. */
    uint16_t        adv_sid;
    uint32_t        reserved;               /* Reserved always set to 0 */
} DM_ULP_EXT_ADV_SET_PARAMS_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_EXT_ADV_SET_PARAMS_CFM
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;                   /* DM_ULP_EXT_ADV_SET_PARAMS_CFM */
    phandle_t       phandle;                /* destination phandle */
    hci_return_t    status;                 /* Success or failure - See Note1 */
    uint8_t         adv_sid;    /* The value being used for this advertising set */
} DM_ULP_EXT_ADV_SET_PARAMS_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Configure how you wish the advertising set to advertise.  Further info can be found
 * in BLUETOOTH CORE SPECIFICATION Version 5.2 and above: LE Set Extended Advertising 
 * Parameters Command. This primitive would usually always follow after a
 * DM_ULP_EXT_ADV_REGISTER_APP_ADV_SET_REQ unless changing existing parameters for an
 * advertising set.
 *
 * Note: If the controller supports Coding Scheme Selection on Advertising (CSSA)
 *       feature, then this command uses HCI_LE_Set_Extended_Advertising_Parameters [v2]
 *       else HCI_LE_Set_Extended_Advertising_Parameters [v1].
 *
 * RETURNS
 *     DM_ULP_EXT_ADV_SET_PARAMS_V2_CFM_T
 *----------------------------------------------------------------------------*/

/* Below macros can be used to set Primary/Secondary Advertising_PHY_Options paramter */
/* No preferred or required coding when transmitting on the LE Coded PHY */
#define DM_ULP_EXT_ADV_PRIMMARY_ADV_PHY_OPTNS_NO_PREF           0x00

/* Prefers S2 coding be used when transmitting on the LE Coded PHY */
#define DM_ULP_EXT_ADV_PRIMMARY_ADV_PHY_OPTNS_PREF_S2           0x01

/* Prefers S8 coding be used when transmitting on the LE Coded PHY */
#define DM_ULP_EXT_ADV_PRIMMARY_ADV_PHY_OPTNS_PREF_S8           0x02

/* Requires S2 coding be used when transmitting on the LE Coded PHY */
#define DM_ULP_EXT_ADV_PRIMMARY_ADV_PHY_OPTNS_REQ_S2            0x03

/* Requires S8 coding be used when transmitting on the LE Coded PHY */
#define DM_ULP_EXT_ADV_PRIMMARY_ADV_PHY_OPTNS_REQ_S8            0x04

/* No preferred or required coding when transmitting on the LE Coded PHY */
#define DM_ULP_EXT_ADV_SECONDARY_ADV_PHY_OPTNS_NO_PREF          0x00

/* Prefers S=2 coding be used when transmitting on the LE Coded PHY */
#define DM_ULP_EXT_ADV_SECONDARY_ADV_PHY_OPTNS_PREF_S2          0x01

/* Prefers S=8 coding be used when transmitting on the LE Coded PHY */
#define DM_ULP_EXT_ADV_SECONDARY_ADV_PHY_OPTNS_PREF_S8          0x02

/* Requires S=2 coding be used when transmitting on the LE Coded PHY */
#define DM_ULP_EXT_ADV_SECONDARY_ADV_PHY_OPTNS_REQ_S2           0x03

/* Requires S=8 coding be used when transmitting on the LE Coded PHY */
#define DM_ULP_EXT_ADV_SECONDARY_ADV_PHY_OPTNS_REQ_S8           0x04

typedef struct
{
    dm_prim_t       type;          /* DM_ULP_EXT_ADV_SET_PARAMS_V2_REQ */
    uint8_t         adv_handle;    /* 0 to DM_ULP_EXT_ADV_MAX_ADV_HANDLES - 1 */

    /* Refer to BLUETOOTH CORE SPECIFICATION Version 5.2 */
    uint16_t        adv_event_properties;     /* EA adv_event_properties in hci.h */
    uint32_t        primary_adv_interval_min; /* 0x000020 to 0xFFFFFF */
    uint32_t        primary_adv_interval_max; /* 0x000020 to 0xFFFFFF */
    uint8_t         primary_adv_channel_map;  /* Advertising_Channel_Map in hci.h */
    uint8_t         own_addr_type;            /* X_Address_Type in hci.h */
    TYPED_BD_ADDR_T peer_addr;                /* Refer peer_addr documentation in DM_ULP_EXT_ADV_SET_PARAMS_REQ_T */
    uint8_t         adv_filter_policy;        /* Advertising_Filter_Policy in hci.h */
    uint16_t        primary_adv_phy;          /* Refer "EA Primary and Secondary advertising
                                                 phys" in hci.h */
    uint8_t         secondary_adv_max_skip;   /* 0 to 0xFF */
    uint16_t        secondary_adv_phy;        /* Refer "EA Primary and Secondary advertising
                                                 phys" in hci.h */

    /* adv_sid can be set to:
       DM_ULP_EXT_ADV_SID_INVALID           - When legacy advertising set to this
       DM_ULP_EXT_ADV_SID_ASSIGNED_BY_STACK - Stack will assign unique value
       0 to 15                              - Application decides unique value
       DM_ULP_EXT_ADV_SID_SHARE + (0 to 15) - More than 1 advertising set can have this
                                              value. */
    uint16_t        adv_sid;
    int8_t          adv_tx_pwr;               /* Maximum power level to be used */
    uint8_t         scan_req_notify_enable;   /* Not supported (RFU), default set
                                                 to 0x00 (Disabled) */

    /* Refer to BLUETOOTH CORE SPECIFICATION Version 5.4 */
    uint8_t         primary_adv_phy_options;   /* See DM_ULP_EXT_ADV_PRIMMARY_ADV_PHY_xxx 
                         Note: Ignored if HCI_LE_Set_Extended_Advertising_Parameters [v1] is used */
    uint8_t         secondary_adv_phy_options; /* See DM_ULP_EXT_ADV_SECONDARY_ADV_PHY_xxx 
                         Note: Ignored if HCI_LE_Set_Extended_Advertising_Parameters [v1] is used */
} DM_ULP_EXT_ADV_SET_PARAMS_V2_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_EXT_ADV_SET_PARAMS_V2_CFM_T
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;            /* DM_ULP_EXT_ADV_SET_PARAMS_V2_CFM */
    phandle_t       phandle;         /* destination phandle */
    hci_return_t    status;          /* Success or failure - See Note1 */
    uint8_t         adv_sid;         /* The value being used for this advertising set */
    int8_t          selected_tx_pwr; /* Controller selected power level */
} DM_ULP_EXT_ADV_SET_PARAMS_V2_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Enable/disable advertising(or Truncated advertising) for an advertising set. 
 * Further info can be found in BLUETOOTH CORE SPECIFICATION Version 
 * 5.2: LE Set Extended Advertising Enable Command
 *
 * RETURNS
 *     DM_ULP_EXT_ADV_ENABLE_CFM_T
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t       type;          /* DM_ULP_EXT_ADV_ENABLE_REQ */
    uint8_t         adv_handle;    /* 1 to DM_ULP_EXT_ADV_MAX_ADV_HANDLES - 1 */
    uint8_t         enable;        /* Advertising_Enable in hci.h */
} DM_ULP_EXT_ADV_ENABLE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_EXT_ADV_ENABLE_CFM
 *---------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_ULP_EXT_ADV_ENABLE_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Enable/disable advertising(or Truncated advertising)  for 1 to 4 advertising sets.
 * Further info can be found in BLUETOOTH CORE SPECIFICATION Version 
 * 5.2: LE Set Extended Advertising Enable Command.
 *
 * Important: It is recommended to set max_ea_events to 0 and duration to 0 if you want
 * Bluestack to temporarily disable advertising when adding/removing entries to the
 * controller's resolving list or white list while advertising on any advertising set.
 * Pairing may result in an entry being written in to the controller's resolving list
 * and DM_SM_REMOVE_DEVICE_REQ may result in entries being removed.  An advertising set
 * that is advertising will also be temporarily disabled if using
 * DM_ULP_EXT_ADV_SET_PARAMS_REQ or DM_ULP_EXT_ADV_SET_RANDOM_ADDR_REQ. Refer to
 * BLUETOOTH CORE SPECIFICATION Version 5.2 on restrictions applying to the following
 * HCI commands to understand why this is done:
 *
 *    LE Set Advertising Set Random Address
 *    LE Set Extended Advertising Parameters
 *    LE Clear White List
 *    LE Add Device To White List
 *    LE Remove Device From White List
 *    LE Add Device To Resolving List
 *    LE Remove Device From Resolving List
 *    LE Clear Resolving List
 *    LE Set Privacy Mode
 *
 * RETURNS
 *     DM_ULP_EXT_ADV_MULTI_ENABLE_CFM_T
 *----------------------------------------------------------------------------*/

/* Max number of advertising sets that can be enabled or disabled in one go */
#define DM_ULP_EXT_ADV_MAX_NUM_ENABLE 4

/* When enabling advertising the advertising will not stop due to duration limit */
#define DM_ULP_EXT_ADV_N0_DURATION 0    /* Apply to duration field */

/* When enabling advertising the advertising will not stop due to max extended
   advertising events limit */
#define DM_ULP_EXT_ADV_NO_MAX_EVENTS 0  /* Apply to max_event field */

typedef struct
{
    uint8_t  adv_handle;         /* 1 to DM_ULP_EXT_ADV_MAX_ADV_HANDLES - 1 */
    uint8_t  max_ea_events;      /* Max number of ext adv events allowed */
    uint16_t duration;           /* How long to advertise */
} EA_ENABLE_CONFIG_T;

typedef struct
{
    dm_prim_t          type;     /* DM_ULP_EXT_ADV_MULTI_ENABLE_REQ */
    uint8_t            enable;   /* Advertising_Enable in hci.h */
    uint8_t            num_sets; /* How many advertising set configs in prim */

    /* What advertising sets to enable/disable and how long to advertise for */
    EA_ENABLE_CONFIG_T config[DM_ULP_EXT_ADV_MAX_NUM_ENABLE];
} DM_ULP_EXT_ADV_MULTI_ENABLE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_EXT_ADV_MULTI_ENABLE_CFM
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;                 /* DM_ULP_EXT_ADV_MULTI_ENABLE_CFM */
    phandle_t       phandle;              /* destination phandle             */
    hci_return_t    status;               /* Success or failure - See Note1  */
    uint8_t         max_adv_sets;         /* Number of adv sets below        */

    /* Current state of all advertising sets with regards advertising. Bit set means
       advertising is enabled for that advertising set. Starting at bit 0 to max
       supported advertising sets (e.g. max_adv_sets).
       Note: Bit 0 is for legacy advertising set used by old LE
             connection/advertising APIs (e.g. ADV_HANDLE_FOR_LEGACY_API). */
    uint32_t        adv_bits;
} DM_ULP_EXT_ADV_MULTI_ENABLE_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Get the address associated with the extended advertisement handle
 *
 * RETURNS
 *     DM_ULP_EXT_ADV_GET_ADDR_CFM_T
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t          type;              /* DM_ULP_EXT_ADV_GET_ADDR_REQ */
    uint8_t            adv_handle;        /* Extended advertisement handle */
} DM_ULP_EXT_ADV_GET_ADDR_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_EXT_ADV_GET_ADDR_CFM
 *---------------------------------------------------------------------------*/
typedef struct 
{
    dm_prim_t          type;              /* DM_ULP_EXT_ADV_GET_ADDR_CFM */
    phandle_t          phandle;           /* destination phandle             */
    hci_return_t       status;            /* Success or failure - See Note1  */
    uint8_t            adv_handle;        /* Extended advertisement handle   */
    TYPED_BD_ADDR_T    addrt;             /* Address associated with extended advertisement */
}DM_ULP_EXT_ADV_GET_ADDR_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Read the max allowed advertising data for an advertising set.
 *
 * RETURNS
 *     DM_ULP_EXT_ADV_READ_MAX_ADV_DATA_LEN_CFM_T
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t       type;         /* DM_ULP_EXT_ADV_READ_MAX_ADV_DATA_LEN_REQ */
    uint8_t         adv_handle;   /* 0 to DM_ULP_EXT_ADV_MAX_ADV_HANDLES - 1  */
} DM_ULP_EXT_ADV_READ_MAX_ADV_DATA_LEN_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_EXT_ADV_READ_MAX_ADV_DATA_LEN_CFM
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;        /* DM_ULP_EXT_ADV_READ_MAX_ADV_DATA_LEN_CFM */
    phandle_t       phandle;     /* destination phandle */
    hci_return_t    status;      /* Success or failure - See Note1 */
    uint16_t        max_adv_data;              /* 0 to 1650 octets */
    uint16_t        max_scan_resp_data;        /* 0 to 1650 octets */
} DM_ULP_EXT_ADV_READ_MAX_ADV_DATA_LEN_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Set the random address for an advertising set. This will allow the user to write a
 * random address or write a generated random address or use global random address
 * which is used for scanning, initiating and legacy adv set. Types of addresses that
 * can be generated and written are Static, Resolvable Private Address (RPA) and
 * Non-Resolvable Private Address (NRPA).
 *
 * RETURNS
 *     DM_ULP_EXT_ADV_SET_RANDOM_ADDR_CFM_T
 *----------------------------------------------------------------------------*/

/* Options for generating or setting a random address for an advertising set.
   Used to set field action. */
#define DM_EXT_ADV_ADDRESS_WRITE_STATIC 0                      /* Set static address */
#define DM_EXT_ADV_ADDRESS_GENERATE_STATIC 1      /* Generate and set static address */
#define DM_EXT_ADV_ADDRESS_GENERATE_NON_RESOLVABLE 2        /* Generate and set NRPA */
#define DM_EXT_ADV_ADDRESS_GENERATE_RESOLVABLE 3             /* Generate and set RPA */
#define DM_EXT_ADV_ADDRESS_WRITE_NON_RESOLVABLE 4                        /* Set NRPA */
#define DM_EXT_ADV_ADDRESS_WRITE_RESOLVABLE 5                             /* Set RPA */

/* Use the global random address instead of one generated or in field random_addr.
   Note) Address is set by DM_SM_AUTO_CONFIGURE_LOCAL_ADDRESS_REQ and maybe updated 
   by bluestack at any point if using NRPA or RPA. This is the only option that 
   supports bluestack running a host based RPA timer for advertising set. */
#define DM_EXT_ADV_ADDRESS_USE_GLOBAL 6

typedef struct
{
    dm_prim_t               type;              /* DM_ULP_EXT_ADV_SET_RANDOM_ADDR_REQ */
    uint8_t                 adv_handle;   /* 1 to DM_ULP_EXT_ADV_MAX_ADV_HANDLES - 1 */
    uint16_t                action;                     /* How to set random address */
    BD_ADDR_T               random_addr;                  /* Random address to write */
} DM_ULP_EXT_ADV_SET_RANDOM_ADDR_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_EXT_ADV_SET_RANDOM_ADDR_CFM
 *
 *     Note: Field random_addr will be invalid if status is an error, but
 *           adv_handle will always be valid.
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t                   type;          /* DM_ULP_EXT_ADV_SET_RANDOM_ADDR_CFM */
    phandle_t                   phandle;                      /* Destination phandle */
    hci_return_t                status;            /* Success or failure - See Note1 */
    uint8_t                     adv_handle;                       /* Advertising set */
    BD_ADDR_T                   random_addr;               /* Random address written */
} DM_ULP_EXT_ADV_SET_RANDOM_ADDR_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Read the global parameters to be used when scanning.
 *
 * RETURNS
 *     DM_ULP_EXT_SCAN_GET_GLOBAL_PARAMS_CFM_T
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;            /* DM_ULP_EXT_SCAN_GET_GLOBAL_PARAMS_REQ */
    phandle_t       phandle;         /* Where to send confirm to */
} DM_ULP_EXT_SCAN_GET_GLOBAL_PARAMS_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_EXT_SCAN_GET_GLOBAL_PARAMS_CFM
 *---------------------------------------------------------------------------*/
#define DM_ULP_EXT_SCAN_MAX_SCANNING_PHYS HCI_ULP_MAX_SCANNING_PHYS

typedef struct
{
    dm_prim_t       type;        /* DM_ULP_EXT_ADV_READ_MAX_ADV_DATA_LEN_CFM */
    phandle_t       phandle;     /* destination phandle */
    hci_return_t    status;      /* Success or failure - See Note1 */

    /* bits 0-1:
       How the AD structure length check is configured.
       0 = Perform AD structure length check not allowing 0 length AD Structure
       1 = Perform AD structure length check allowing for 0 length AD Structure
       2 = No AD structure length check

       bits 2-7:
       Reserved for future use. */
    uint8_t         flags;

    uint8_t         own_address_type;             /* X_Address_Type in hci.h */
    uint8_t         scanning_filter_policy;       /* Scanning_Filter_Policy in hci.h */
    uint8_t         filter_duplicates;    /* Refer to filter duplicate defines below */

    /* For each scanning_phys bit set expect an entry in phys starting with bit 0:
       bit0 = Scan LE 1M on the primary advertising channel
       bit2 = Scan LE Coded on the primary advertising channel */
    uint16_t        scanning_phys;
    ES_SCANNING_PHY_T   phys[DM_ULP_EXT_SCAN_MAX_SCANNING_PHYS];
} DM_ULP_EXT_SCAN_GET_GLOBAL_PARAMS_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Write the global parameters to be used when scanning.  This maybe called when
 * scanners are scanning or not scanning, to allow the application to change behaviour.
 * Scanners will adapt to any new constraints automatically, but should ideally only be
 * sent at startup if only needed to be set once.
 *
 * Note: An AD Structure length check can be enabled that will cause any advertising
 *       reports that fail the test to be dropped. The check verifies that the total
 *       length of advertising data adds up to the sum of all AD Structure length 
 *       fields. Refer to options below.
 *
 * RETURNS
 *     DM_ULP_EXT_SCAN_SET_GLOBAL_PARAMS_CFM_T
 *----------------------------------------------------------------------------*/

/* The following defines say how the filter duplicates will work. The controller's
   DID cache will be enabled when set ON or a period set.  Setting a scan period will
   mean the DID cache will be flushed at the start of each scan period. */
#define DM_ULP_EXT_SCAN_FILTER_DUPLICATE_OFF HCI_ULP_FILTER_DUPLICATES_DISABLED
#define DM_ULP_EXT_SCAN_FILTER_DUPLICATE_ON HCI_ULP_FILTER_DUPLICATES_ENABLED
#define DM_ULP_EXT_SCAN_FILTER_DUPLICATE_1SEC_PERIOD 2   /* 1.28 seconds   */
#define DM_ULP_EXT_SCAN_FILTER_DUPLICATE_2SEC_PERIOD 3   /* 2.56 seconds   */
#define DM_ULP_EXT_SCAN_FILTER_DUPLICATE_5SEC_PERIOD 4   /* 5.12 seconds   */
#define DM_ULP_EXT_SCAN_FILTER_DUPLICATE_10SEC_PERIOD 5  /* 10.24 seconds  */
#define DM_ULP_EXT_SCAN_FILTER_DUPLICATE_30SEC_PERIOD 6  /* 30.72 seconds  */
#define DM_ULP_EXT_SCAN_FILTER_DUPLICATE_1MIN_PERIOD 7   /* 60.16 seconds  */
#define DM_ULP_EXT_SCAN_FILTER_DUPLICATE_2MIN_PERIOD 8   /* 120.32 seconds */
#define DM_ULP_EXT_SCAN_FILTER_DUPLICATE_5MIN_PERIOD 9   /* 300.80 seconds */
#define DM_ULP_EXT_SCAN_FILTER_DUPLICATE_10MIN_PERIOD 10 /* 600.32 seconds */

/* Used for single scan (Duration non-zero but Period zero).

   Period parameter in the HCI_ULP_EXT_SCAN_ENABLE command will be set to zero.
   Only the duration parameter is considered from the above 
   configurations (DM_ULP_EXT_SCAN_FILTER_DUPLICATE_xxx).

   Note: 1) Shall be OR'ed with one of the DM_ULP_EXT_SCAN_FILTER_DUPLICATE_xxx value
            greater than DM_ULP_EXT_SCAN_FILTER_DUPLICATE_ON (non-zero duration).
         2) DM_ULP_EXT_SCAN_TIMEOUT_IND shall be sent at the end of
            single scan in the controller.
         3) Disables all the other scanners if active and DM_ULP_EXT_SCAN_CTRL_SCAN_INFO_IND 
            shall be sent.
         4) Filter duplicate shall be enabled.

   Example: To perform single scan for a duration of 5.12 seconds. Set,
            filter_duplicates = ( DM_ULP_EXT_SCAN_FILTER_DUPLICATE_5SEC_PERIOD |
                                  DM_ULP_EXT_SCAN_FILTER_DUPLICATE_MASK_PERIOD)
   */
#define DM_ULP_EXT_SCAN_FILTER_DUPLICATE_MASK_PERIOD 0x80

typedef struct
{
    dm_prim_t       type;          /* DM_ULP_EXT_SCAN_SET_GLOBAL_PARAMS_REQ */
    phandle_t       phandle;       /* Where to send confirm to */

    /* bits 0-1:
       Bits to setup the AD structure length check. If this check fails the advertising
       report will be dropped.
       0 = Perform AD structure length check not allowing 0 length AD Structure
       1 = Perform AD structure length check allowing for 0 length AD Structure
       2 = No AD structure length check

       bits 2-7:
       Reserved for future use always set to 0. */
    uint8_t         flags;

    uint8_t         own_address_type;             /* X_Address_Type in hci.h */
    uint8_t         scanning_filter_policy;       /* Scanning_Filter_Policy in hci.h */
    uint8_t         filter_duplicates;    /* Refer to filter duplicate defines above */

    /* For each scanning_phys bit set expect an entry in phys starting with bit 0:
       bit0 = Scan LE 1M on the primary advertising channel
       bit2 = Scan LE Coded on the primary advertising channel
       All other bits should be set to 0 */
    uint16_t        scanning_phys;
    ES_SCANNING_PHY_T phys[DM_ULP_EXT_SCAN_MAX_SCANNING_PHYS];
} DM_ULP_EXT_SCAN_SET_GLOBAL_PARAMS_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_EXT_SCAN_SET_GLOBAL_PARAMS_CFM
 *---------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_ULP_EXT_SCAN_SET_GLOBAL_PARAMS_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Register a bluestack scanner and filter rules.  The filter rules allows a scanner 
 * to only report advertising reports that meet specified filter criteria. Only 
 * filters that match will have the registered scan_handle set in the scan_handles 
 * field of the advertising report (DM_ULP_EXT_SCAN_FILTERED_ADV_REPORT_IND_T).  
 * Advertising reports may still be reported if other scanners matching their filter  
 * rules.  If no scanners match then the advertising report will be dropped.
 *
 * RETURNS
 *     DM_ULP_EXT_SCAN_REGISTER_SCANNER_CFM_T
 *
 *     Note: The confirm will return a scan_handle to be used in other extended scan
 *           primitives to access the registered scanner.
 *----------------------------------------------------------------------------*/
#define DM_ULP_EXT_SCAN_MAX_REG_AD_TYPES 10

/* AD Structure flags filter part of flags field (bits 0-1) */
#define DM_ULP_EXT_SCAN_AD_FLAGS_MASK        3 /* Flags AD Structure mask */

#define DM_ULP_EXT_SCAN_AD_FLAGS_NO_FILTER   0 /* Flags AD Structure filter disabled */
#define DM_ULP_EXT_SCAN_AD_FLAGS_PRESENT     1 /* Only report if flags AD type present */
#define DM_ULP_EXT_SCAN_AD_FLAGS_GEN_AND_LIM 2 /* Only report if flags general or limited bit set */
#define DM_ULP_EXT_SCAN_AD_FLAGS_LIM         3 /* Only report if flags limited bit set */

/* Valid values for adv_filter field */
#define DM_ULP_EXT_SCAN_ADV_FILTER_NONE 0
#define DM_ULP_EXT_SCAN_ADV_FILTER_BLOCK_ALL 1
#define DM_ULP_EXT_SCAN_ADV_FILTER_LEGACY 2
#define DM_ULP_EXT_SCAN_ADV_FILTER_EXTENDED 3
#define DM_ULP_EXT_SCAN_ADV_FILTER_ASSOCIATED_PERIODIC 4

/* Valid values for ad_structure_filter field */
#define DM_ULP_EXT_SCAN_AD_STRUCT_FILTER_NONE 0

/* Sub fields setting for adv_filter or ad_structure_filter when not used */
#define DM_ULP_EXT_SCAN_SUB_FIELD_INVALID 0

/* Used to calculate number of dynamic array pointers in field ad_structure_info.
   It is declared here rather than hci.h as ad_structure_info in DM_ULP_EXT_SCAN_REGISTER_SCANNER_REQ
   and DM_ULP_PERIODIC_SCAN_START_FIND_TRAINS_REQ does not go to controller */
#define DM_ULP_AD_STRUCT_INFO_LENGTH         255
#define DM_ULP_AD_STRUCT_INFO_BYTES_PER_PTR  HCI_VAR_ARG_POOL_SIZE
#define DM_ULP_AD_STRUCT_INFO_BYTE_PTRS      ((DM_ULP_AD_STRUCT_INFO_LENGTH + DM_ULP_AD_STRUCT_INFO_BYTES_PER_PTR -1) / DM_ULP_AD_STRUCT_INFO_BYTES_PER_PTR)

typedef struct
{
    dm_prim_t       type;          /* DM_ULP_EXT_SCAN_REGISTER_SCANNER_REQ */
    phandle_t       phandle;       /* Where to send confirm and indications for this scanner. */

    /* bits 0-1:
       Flags AD structure filter defines above.
       0 = Report all
       1 = Report advertising reports with flags AD type
       2 = Report advertising reports with flags AD type with LE Limited Discoverable
           Mode set or LE General Discoverable Mode set.
       3 = Report advertising reports with flags AD type with LE Limited Discoverable
           Mode set

       bits 2-7:
       Reserved for future use always set to 0. */
    uint32_t        flags;

    /* adv_filter defines above.
       0 = Receive all advertising reports
       1 = Do not receive any advertising reports
       2 = Only receive advertising reports with legacy advertising
       3 = Only receive advertising reports with extended advertising
       4 = Only receive advertising reports with extended advertising and sync info
           associated to a periodic train */
    uint16_t        adv_filter;
    uint16_t        adv_filter_sub_field1;  /* Future option always set to 0 */
    uint32_t        adv_filter_sub_field2;  /* Future option always set to 0 */

    /* Future option set all below fields to 0 */
    uint16_t        ad_structure_filter;
    uint16_t        ad_structure_filter_sub_field1;
    uint32_t        ad_structure_filter_sub_field2;
    uint16_t        ad_structure_info_len;
    uint8_t        *ad_structure_info[DM_ULP_AD_STRUCT_INFO_BYTE_PTRS];
} DM_ULP_EXT_SCAN_REGISTER_SCANNER_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_EXT_SCAN_REGISTER_SCANNER_CFM
 *---------------------------------------------------------------------------*/
#define DM_ULP_EXT_SCAN_HANDLE_INVALID 0xFF

typedef struct
{
    dm_prim_t       type;          /* DM_ULP_EXT_SCAN_REGISTER_SCANNER_CFM */
    phandle_t       phandle;       /* destination phandle */
    hci_return_t    status;        /* Success or failure - See Note1 */
    uint8_t         scan_handle;   /* Scan handle for registered scanner */
} DM_ULP_EXT_SCAN_REGISTER_SCANNER_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Unregister a scanner which was originally registered using
 * DM_ULP_EXT_SCAN_REGISTER_SCANNER_REQ, so making the scanner available for others to
 * use.
 *
 * RETURNS
 *     DM_ULP_EXT_SCAN_UNREGISTER_SCANNER_CFM_T
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;           /* DM_ULP_EXT_SCAN_UNREGISTER_SCANNER_REQ */
    phandle_t       phandle;        /* Where to send confirm */
    uint8_t         scan_handle;    /* Scanner to unregister */
} DM_ULP_EXT_SCAN_UNREGISTER_SCANNER_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_EXT_SCAN_UNREGISTER_SCANNER_CFM
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;          /* DM_ULP_EXT_SCAN_UNREGISTER_SCANNER_CFM */
    phandle_t       phandle;       /* destination phandle */
    hci_return_t    status;        /* Success or failure - See Note1 */
} DM_ULP_EXT_SCAN_UNREGISTER_SCANNER_CFM_T;

#ifndef EXCLUDE_AE_REPORTS
/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Configure a scanner. DO NOT USE
 *
 * RETURNS
 *     DM_ULP_EXT_SCAN_CONFIGURE_SCANNER_CFM_T
 *----------------------------------------------------------------------------*/
typedef struct
{
    uint8_t         use_scan_defaults;
    uint8_t         scan_type;
    uint16_t        scan_interval;
    uint8_t         scan_window;
} DM_ULP_EXT_SCAN_PHY_T;

typedef struct
{
    dm_prim_t       type;            /* DM_ULP_EXT_SCAN_CONFIGURE_SCANNER_REQ */
    phandle_t       phandle;         /* Where to send confirm */
    uint8_t         scan_handle;     /* Scanner to configure */
    uint8_t         use_only_global_params;
    uint16_t        scanning_phys;
    DM_ULP_EXT_SCAN_PHY_T   phys[DM_ULP_EXT_SCAN_MAX_SCANNING_PHYS];
} DM_ULP_EXT_SCAN_CONFIGURE_SCANNER_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_EXT_SCAN_CONFIGURE_SCANNER_CFM
 *---------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_ULP_EXT_SCAN_CONFIGURE_SCANNER_CFM_T;
#endif /* EXCLUDE_AE_REPORTS */

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Enable or disable 1 or more scanners. If field duration is set to a none zero value
 * and enabling scanning then a scanner will run for a specified time.  When this time
 * expires the scanner will be disabled and a DM_ULP_EXT_SCAN_DURATION_EXPIRED_IND sent
 * to application.
 *
 * Note: There is only 1 LE controller scanner that is shared by all bluestack scanners
 *       so the LE controller scanner will be active if 1 or more scanners have been
 *       enabled, else disabled. Re-enabling an enabled scanner will force a re-enable
 *       of the LE controller scanner so flushing the DID cache. The same thing will
 *       happen if the LE controller scanner is active and a new scanner is
 *       enabled. This does mean when duplicate filtering is enabled that scanners
 *       should expect to sometimes receive duplicate advertising reports in these
 *       situations.  Duplicate advertising reports will also occur at the end of a
 *       filter duplicates period or when the DID cache is full.
 *
 * RETURNS
 *     DM_ULP_EXT_SCAN_ENABLE_SCANNERS_CFM
 *----------------------------------------------------------------------------*/
#define DM_ULP_EXT_SCAN_MAX_SCANNERS 5
#define DM_ULP_EXT_SCAN_FOREVER 0
#define DM_ULP_MAX_EXT_SCAN_DURATION 3600 /* seconds */

typedef struct
{
    uint8_t         scan_handle;      /* Scanner to enable/disable */

    /* How long to scan for in seconds when enabling a scanner.
       0 = DM_ULP_EXT_SCAN_FOREVER (Scan until stopped by application)
       1 to DM_ULP_MAX_EXT_SCAN_DURATION = How long to scan for (seconds) */
    uint16_t        duration;
} DM_ULP_EXT_SCAN_SCANNERS_T;

typedef struct
{
    dm_prim_t       type;             /* DM_ULP_EXT_SCAN_ENABLE_SCANNERS_REQ */
    phandle_t       phandle;          /* Where to send confirm */
    uint8_t         enable;           /* LE_Scan_Enable in hci.h */
    uint8_t         num_of_scanners;  /* 1 to DM_ULP_EXT_SCAN_MAX_SCANNERS */
    DM_ULP_EXT_SCAN_SCANNERS_T   scanners[DM_ULP_EXT_SCAN_MAX_SCANNERS];
} DM_ULP_EXT_SCAN_ENABLE_SCANNERS_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_EXT_SCAN_ENABLE_SCANNERS_CFM
 *---------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_ULP_EXT_SCAN_ENABLE_SCANNERS_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Get information on how the LE controller's scanner has been configured and how
 * many bluestack scanners are using it.
 *
 * RETURNS
 *     DM_ULP_EXT_SCAN_GET_CTRL_SCAN_INFO_CFM_T
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;          /* DM_ULP_EXT_SCAN_GET_CTRL_SCAN_INFO_REQ */
    phandle_t       phandle;       /* Where to send confirm */
} DM_ULP_EXT_SCAN_GET_CTRL_SCAN_INFO_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_EXT_SCAN_GET_CTRL_SCAN_INFO_CFM
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;          /* DM_ULP_EXT_SCAN_GET_CTRL_SCAN_INFO_CFM */
    phandle_t       phandle;       /* destination phandle */
    hci_return_t    status;                   /* Success or failure - See Note1 */
    uint8_t         num_of_enabled_scanners;  /* Number of enabled bluestack scanners */
    uint8_t         legacy_scanner_enabled;   /* Is legacy api scanner enabled */
    uint16_t        duration;                 /* Reserved for future use */

    /* For each scanning_phys bit set expect an entry in phys starting with bit 0:
       bit0 = Scan LE 1M on the primary advertising channel
       bit2 = Scan LE Coded on the primary advertising channel */
    uint16_t        scanning_phys;
    ES_SCANNING_PHY_T phys[DM_ULP_EXT_SCAN_MAX_SCANNING_PHYS];
} DM_ULP_EXT_SCAN_GET_CTRL_SCAN_INFO_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This event says how the LE controller's scanner has been configured and how many
 * bluestack scanners are using it. Sent when ever a scanner is enabled/disabled or
 * when bluestack receives DM_ULP_EXT_SCAN_SET_GLOBAL_PARAMS_REQ and 1 or more scanners
 * are enabled. The reason field will say why the event was triggered.
 *---------------------------------------------------------------------------*/

/* Valid values for reason field */
#define DM_ULP_EXT_SCAN_REASON_GLOBALS_CHANGED 0
#define DM_ULP_EXT_SCAN_REASON_SCANNERS_ENABLED 1
#define DM_ULP_EXT_SCAN_REASON_SCANNERS_DISABLED 2

typedef struct
{
    dm_prim_t       type;          /* DM_ULP_EXT_SCAN_CTRL_SCAN_INFO_IND */
    phandle_t       phandle;       /* destination phandle */
    uint8_t         reason;        /* reason defines above */
    uint8_t         controller_updated;  /* LE Set Extended Scan Enable command sent */
    uint8_t         num_of_enabled_scanners; /* Number of enabled bluestack scanners */
    uint8_t         legacy_scanner_enabled;  /* Is legacy api scanner enabled */
    uint16_t        duration;                /* Reserved for future use */

    /* For each scanning_phys bit set expect an entry in phys starting with bit 0:
       bit0 = Scan LE 1M on the primary advertising channel
       bit2 = Scan LE Coded on the primary advertising channel */
    uint16_t        scanning_phys;
    ES_SCANNING_PHY_T phys[DM_ULP_EXT_SCAN_MAX_SCANNING_PHYS];
} DM_ULP_EXT_SCAN_CTRL_SCAN_INFO_IND_T;

/*----------------------------------------------------------------------------*
 * Bit definitions used for extended advertising reports adv_data_info field
 *----------------------------------------------------------------------------*/
/* AD Structures chain validity (Bits 0-1 in adv_data_info field) */
#define DM_ULP_EXT_SCAN_AD_STRUCTS_MASK      3 /* AD Structure validity mask */

#define DM_ULP_EXT_SCAN_AD_STRUCTS_OK        0 /* Valid chain of AD Structures */
#define DM_ULP_EXT_SCAN_AD_STRUCTS_ZERO_LEN  1 /* AD structure chain was terminated with
                                                  a 0 length AD Structure */
#define DM_ULP_EXT_SCAN_AD_STRUCTS_LEN_ERROR 2 /* AD Structure length check failed */

/* Flags AD Structure present (Bit 7 in adv_data_info field) */
#define DM_ULP_EXT_SCAN_AD_FLAGS_IS_PRESENT  0x80 /* If set ad_flags field is valid */

#ifndef EXCLUDE_AE_REPORTS
/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This event will notify a primitive handler that 1 or more extended scanners have
 * matched an advertising report.  The event contains the advertising report.
 *
 * NOTE
 *
 * Typed Bluetooth device addresses are used in this event but are not in usual format.
 * This is to keep the memory footprint small. Usual format is TYPED_BD_ADDR_T rather
 * than *_addr_type and *_addr.
 *
 * RETURNS
 *     None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t type;
    phandle_t phandle;

    /* The presence of 1 or more scan_handles indicates that the advertising report
       matches 1 or more scanner's filters */
    uint8_t num_of_scan_handles;
    uint8_t scan_handles[DM_ULP_EXT_SCAN_MAX_SCANNERS];

    /* Refer to BLUETOOTH CORE SPECIFICATION Version 5.2: LE Extended Advertising Report
       event */
    uint16_t event_type;
    uint16_t primary_phy;
    uint16_t secondary_phy;
    uint8_t adv_sid;
    uint8_t current_addr_type;
    uint8_t permanent_addr_type;
    uint8_t direct_addr_type;
    BD_ADDR_T current_addr;
    BD_ADDR_T permanent_addr;
    BD_ADDR_T direct_addr;
    int8_t tx_power;
    int8_t rssi;
    uint16_t periodic_adv_interval;

    uint8_t adv_data_info;      /* Refer to adv_data_info field defines above */
    uint8_t ad_flags;           /* The flags from Flags AD Structure */

    /* Advertising data */
    uint16_t adv_data_len;      /* Length of adv data (must be 0 to indicate MBLK) */
    MBLK_T *adv_data;
} DM_ULP_EXT_SCAN_FILTERED_ADV_REPORT_IND_T;
#endif /* EXCLUDE_AE_REPORTS */

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_HCI_ULP_EXT_ADV_SET_DATA_CFM
 *---------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_EXT_ADV_SET_DATA_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_HCI_ULP_EXT_ADV_SET_SCAN_RESP_DATA_CFM
 *---------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_EXT_ADV_SET_SCAN_RESP_DATA_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_HCI_ULP_PERIODIC_ADV_SET_DATA_CFM
 *---------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_PERIODIC_ADV_SET_DATA_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Configure how you wish the advertising set to periodic advertise. The
 * associated advertising set must have been configured using
 * DM_ULP_EXT_ADV_SET_PARAMS_REQ before sending this primitive.
 *
 * RETURNS
 *     DM_ULP_PERIODIC_ADV_SET_PARAMS_CFM_T
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;                   /* DM_ULP_PERIODIC_ADV_SET_PARAMS_REQ */
    uint8_t         adv_handle;        /* 1 to DM_ULP_EXT_ADV_MAX_ADV_HANDLES - 1 */
    uint32_t        flags;                      /* Future option always set to 0  */

    /* Refer to BLUETOOTH CORE SPECIFICATION Version 5.2: LE Set Periodic Advertising
       Parameters command */
    uint16_t        periodic_adv_interval_min;  /* 0x6 to 0xFFFFFF  (N * 1.25 ms) */
    uint16_t        periodic_adv_interval_max;  /* 0x6 to 0xFFFFFF  (N * 1.25 ms) */
    uint16_t        periodic_adv_properties;
} DM_ULP_PERIODIC_ADV_SET_PARAMS_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_PERIODIC_ADV_SET_PARAMS_CFM
 *---------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_ULP_PERIODIC_ADV_SET_PARAMS_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Request to read the max allowed periodic advertising data available to be
 * used for an advertising set.
 *
 * RETURNS
 *     DM_ULP_PERIODIC_ADV_READ_MAX_ADV_DATA_LEN_CFM_T
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;    /* DM_ULP_PERIODIC_ADV_READ_MAX_ADV_DATA_LEN_REQ */
    uint8_t         adv_handle;    /* 1 to DM_ULP_EXT_ADV_MAX_ADV_HANDLES - 1 */
} DM_ULP_PERIODIC_ADV_READ_MAX_ADV_DATA_LEN_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_PERIODIC_ADV_READ_MAX_ADV_DATA_LEN_CFM
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* Success or failure - See Note1 */
    uint16_t            max_adv_data;       /* 0 to 1650 octets */
} DM_ULP_PERIODIC_ADV_READ_MAX_ADV_DATA_LEN_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Starts a periodic advertising train. Periodic advertising will be enabled followed
 * by enabling extended advertising if it has not been enabled.
 *
 * Note: This primitive will enable ADI field in AUX_SYNC_IND PDU if the controller
 *       supports Periodic Advertising ADI feature.
 *
 * RETURNS
 *     DM_ULP_PERIODIC_ADV_START_CFM_T
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;                    /* DM_ULP_PERIODIC_ADV_START_REQ */
    uint8_t         adv_handle;    /* 1 to DM_ULP_EXT_ADV_MAX_ADV_HANDLES - 1 */
} DM_ULP_PERIODIC_ADV_START_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_PERIODIC_ADV_START_CFM
 *---------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_ULP_PERIODIC_ADV_START_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Stops a periodic advertising train or just the associated extended advertising
 * depending on how stop_advertising field is configured.
 *
 * RETURNS
 *     DM_ULP_PERIODIC_ADV_STOP_CFM_T
 *----------------------------------------------------------------------------*/

/* Valid values for stop_advertising field */
#define DM_PERIODIC_ADV_STOP_PA 0          /* Stop periodic advertising only */
#define DM_PERIODIC_ADV_STOP_EA_THEN_PA 1  /* Stop periodic advertising and associated
                                              extended advertising */
#define DM_PERIODIC_ADV_STOP_EA 2          /* Stop extended advertising only */

typedef struct
{
    dm_prim_t       type;                    /* DM_ULP_PERIODIC_ADV_STOP_REQ */
    uint8_t         adv_handle;   /* 1 to DM_ULP_EXT_ADV_MAX_ADV_HANDLES - 1 */
    uint8_t         stop_advertising;              /* Refer to defines above */
} DM_ULP_PERIODIC_ADV_STOP_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_PERIODIC_ADV_STOP_CFM
 *---------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_ULP_PERIODIC_ADV_STOP_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Enable/disable a periodic advertising train. To enable set enable bit
 * DM_PERIODIC_ADV_ENABLE. An enabled train will only start transmitting once associated
 * extended advertising has been started. This can be done at the same time by setting
 * flags bit DM_PERIODIC_ADV_ENABLE_PA_THEN_AE. ADI field will be present in
 * periodic advertising train PDUs if enable bit DM_PERIODIC_ADV_ADI is set. This
 * allows peer devices to use filter duplicates option on periodic advertising reports.
 *
 * When enable bit DM_PERIODIC_ADV_ENABLE is NOT set a train will be disabled. You can
 * use DM_PERIODIC_ADV_DISABLE to do this. The associated extended advertising can be
 * disabled at the same time by setting flags bit DM_PERIODIC_ADV_DISABLE_EA_THEN_PA.
 *
 * Note: This can be used instead of DM_ULP_PERIODIC_ADV_START_REQ and
 *       DM_ULP_PERIODIC_ADV_STOP_REQ.
 *
 * RETURNS
 *     DM_ULP_PERIODIC_ADV_ENABLE_CFM_T
 *----------------------------------------------------------------------------*/
/* Flags field bit defines */
#define DM_PERIODIC_ADV_ENABLE_PA_THEN_EA  ((uint16_t) 0x0001)
#define DM_PERIODIC_ADV_DISABLE_EA_THEN_PA ((uint16_t) 0x0002)

/* Enable field bit defines */
#define DM_PERIODIC_ADV_DISABLE    ((uint8_t) 0x00)
#define DM_PERIODIC_ADV_ENABLE     HCI_ULP_PERIODIC_ADV_EN
#define DM_PERIODIC_ADV_ADI        HCI_ULP_PERIODIC_ADV_ADI

typedef struct
{
    dm_prim_t type;       /* DM_ULP_PERIODIC_ADV_ENABLE_REQ */
    uint8_t   adv_handle; /* 1 to DM_ULP_EXT_ADV_MAX_ADV_HANDLES - 1 */

    /* Flags field (bit defines above)
       bit 0: If set enable extended advertising while enabling
              periodic advertising. (This bit does nothing if extended advertising is
              already enabled)
       bit 1: If set disable extended advertising while disabling periodic
              advertising. (This bit does nothing if extended advertising is already
              disabled) */
    uint16_t  flags;

    /* Enable field (bit defines above)
       bit 0: If set enable periodic advertising, else disable.
       bit 1: If set add ADI field to AUX_SYNC_IND PDU when enabling periodic
              advertising. */
    uint8_t   enable;
} DM_ULP_PERIODIC_ADV_ENABLE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_PERIODIC_ADV_ENABLE_CFM
 *---------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_ULP_PERIODIC_ADV_ENABLE_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     Using the advertising handle currently assigned to a periodic advertising
 *     set, instruct the Controller to transfer SyncInfo for to this PA train
 *     to a connected peer. This will allow the peer's Controller to synchronise
 *     to this PA train.
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* Destination phandle */
    TYPED_BD_ADDR_T     addrt;              /* Address of peer device */
    uint16_t            service_data;       /* Service data for peer's Host */
    uint8_t             adv_handle;         /* Identifies the adv. set to local Controller */
} DM_ULP_PERIODIC_ADV_SET_TRANSFER_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     Confirmation that the local Controller has received the instruction to
 *     transfer SyncInfo for an active advertising set to a connected peer.
 *     Note that this message does not indicate that the remote Controller has
 *     synchronised successfully to the related PA train. A status of SUCCESS
 *     only indicates that the local Controller has completed the PAST Link Layer
 *     Control Procedure.
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* Destination phandle */
    uint8_t             adv_handle;         /* Identifies advertising set */
    uint16_t            status;             /* Success or failure or pending */
} DM_ULP_PERIODIC_ADV_SET_TRANSFER_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This primitive will start extended scanning with a filter that only matches
 * extended advertising reports that contains sync info for a periodic train.
 * Any matches will be sent to the application. In order to do this it will register for
 * a scanner and enable it.
 *
 * Note: This primitive will setup extended scanning to scan forever or for a period of
 *       time depending on how field scan_for_x_seconds is configured. A
 *       DM_ULP_EXT_SCAN_DURATION_EXPIRED_IND will be sent to application when the
 *       scanner is disabled due to the end of the period of time. The scanner will also
 *       be unregistered at this point.
 *
 * RETURNS
 *     DM_ULP_PERIODIC_SCAN_START_FIND_TRAINS_CFM
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t  type;      /* DM_ULP_PERIODIC_SCAN_START_FIND_TRAINS_REQ */
    phandle_t  phandle;   /* Where to send confirm and indications for this scanner. */

    /* bits 0-1:
       Flags AD structure filter defines with DM_ULP_EXT_SCAN_REGISTER_SCANNER_REQ
       above.
       0 = Report all
       1 = Report advertising reports with flags AD type
       2 = Report advertising reports with flags AD type with LE Limited Discoverable
           Mode set or LE General Discoverable Mode set.
       3 = Report advertising reports with flags AD type with LE Limited Discoverable
           Mode set

       bits 2-7:
       Reserved for future use always set to 0. */
    uint32_t   flags;

    /* How long to scan for in seconds.
       0 = DM_ULP_EXT_SCAN_FOREVER (Scan until stopped by
                                    DM_ULP_PERIODIC_SCAN_STOP_FIND_TRAINS_REQ)
       1 to DM_ULP_MAX_EXT_SCAN_DURATION = How long to scan for (seconds) */
    uint16_t   scan_for_x_seconds;

    /* Future option set all below fields to 0 */
    uint16_t   ad_structure_filter;
    uint16_t   ad_structure_filter_sub_field1;
    uint32_t   ad_structure_filter_sub_field2;
    uint16_t   ad_structure_info_len;
    uint8_t   *ad_structure_info[DM_ULP_AD_STRUCT_INFO_BYTE_PTRS];
} DM_ULP_PERIODIC_SCAN_START_FIND_TRAINS_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_PERIODIC_SCAN_START_FIND_TRAINS_CFM
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* destination phandle */
    uint8_t             status;             /* Success or failure - See Note1 */
    uint8_t             scan_handle;        /* Scanner that will scan for trains */
} DM_ULP_PERIODIC_SCAN_START_FIND_TRAINS_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Stop scanning for periodic trains.  This will stop a scanner that was started using
 * DM_ULP_PERIODIC_SCAN_START_FIND_TRAINS_REQ.  It will also unregister the scanner.
 *
 * RETURNS
 *     DM_ULP_PERIODIC_SCAN_STOP_FIND_TRAINS_CFM
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;            /* DM_ULP_PERIODIC_SCAN_STOP_FIND_TRAINS_REQ */
    phandle_t       phandle;         /* Where to send confirm */
    uint8_t         scan_handle;     /* The scanner that is scanning for trains */
} DM_ULP_PERIODIC_SCAN_STOP_FIND_TRAINS_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_PERIODIC_SCAN_STOP_FIND_TRAINS_CFM
 *---------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_ULP_PERIODIC_SCAN_STOP_FIND_TRAINS_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Attempt to sync to one of X periodic trains. The primitive will initially return
 * status DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_PENDING followed by HCI_SUCCESS when synced
 * to a periodic train.  Only one attempt to sync to trains can be in progress at one
 * time.  The attempt to sync can be cancelled by sending a
 * DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CANCEL_REQ.
 *
 * Note: This primitive will start extended scanning. In order to do this it will
 * register for a bluestack scanner and enable it. The scanner will be disabled and
 * unregistered when train is synced or attempt_sync_for_x_seconds expires or an error
 * occurs.
 *
 * RETURNS
 *     DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CFM
 *----------------------------------------------------------------------------*/
#define DM_MAX_PERIODIC_TRAIN_LIST_SIZE 3
#define DM_MAX_PERIODIC_TIMER_TIME DM_ULP_MAX_EXT_SCAN_DURATION    /* seconds */

/* Bluetooth address and advertising SID of a periodic train.  Can be found using
   DM_ULP_PERIODIC_SCAN_START_FIND_TRAINS_REQ */
typedef struct
{
    uint8_t         adv_sid;         /* Advertising SID (0 - 15) */
    TYPED_BD_ADDR_T addrt;           /* Bluetooth address and type */
} DM_ULP_PERIODIC_SCAN_TRAINS_T;

typedef struct
{
    dm_prim_t       type;            /* DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_REQ */
    phandle_t       phandle;         /* Where to send confirm and indications for this periodic train. */

    /* How to handle periodic advertising reports.
       bit 0:
           If set enable the reporting of periodic advertising reports.
       bit 1:
           If set enable duplicate filtering of periodic advertising reports.
       bit 2-7: Reserved set to 0
       Note: Bit defines same as enable field in
             DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_ENABLE_REQ. Refer here for defines. */
    uint8_t         report_periodic;

    uint16_t        skip;            /* 0x0000 to 0x01F3 (Max periodic advertising
                                        events that can be skipped) */
    uint16_t        sync_timeout;    /* 0x000A to 0x4000 (Time = sync_timeout*10 ms) */
    uint8_t         sync_cte_type;   /* Future option always set to 0 */

    /* How long to scan for in seconds.
       0 = DM_ULP_EXT_SCAN_FOREVER (Scan until stopped by
                                    DM_ULP_PERIODIC_SCAN_STOP_FIND_TRAINS_REQ)
       1 to DM_MAX_PERIODIC_TIMER_TIME = How long to scan for (seconds) */
    uint16_t        attempt_sync_for_x_seconds;

    /* A list of periodic trains to try to sync to. The list size limit can be read
       using DM_ULP_GET_ADV_SCAN_CAPABILITIES_REQ. Max list size supported by this
       primitive is DM_MAX_PERIODIC_TRAIN_LIST_SIZE */
    uint8_t         number_of_periodic_trains;
    DM_ULP_PERIODIC_SCAN_TRAINS_T  periodic_trains[DM_MAX_PERIODIC_TRAIN_LIST_SIZE];
} DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CFM
 *---------------------------------------------------------------------------*/
#define DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_PENDING 0xFFFF

typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* destination phandle */
    uint16_t            status;             /* Success or failure or pending */
    uint16_t            sync_handle;        /* The handle for the synced train */
    uint8_t             adv_sid;            /* The synced train's Advertising SID */
    TYPED_BD_ADDR_T     addrt;              /* The synced train's bluetooth address */
    uint8_t             adv_phy;                /* Phy train is advertising on */
    uint16_t            periodic_adv_interval;  /* Periodic advertising interval */
    uint8_t             adv_clock_accuracy;     /* Clock accuracy (0 to 7) */
} DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Cancel establishing sync to a periodic train.  The associated bluestack scanner
 * will be disabled and unregistered.
 *
 * RETURNS
 *     DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CANCEL_CFM
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;            /* DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CANCEL_REQ */
    phandle_t       phandle;         /* Where to send confirm. */
} DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CANCEL_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CANCEL_CFM
 *---------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CANCEL_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Configures for a synced train if periodic advertising reports should be reported 
 * and if duplicate filtering should be enabled.
 *
 * RETURNS
 *     DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_ENABLE_CFM
 *----------------------------------------------------------------------------*/

/* Bit field defines for enable field below and report_periodic field in
   DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_REQ */
#define DM_PERIODIC_SCAN_SYNC_ENABLE_REPORTS             HCI_ULP_ENABLE_PERIODIC_REPORTS
#define DM_PERIODIC_SCAN_SYNC_ENABLE_DUPLICATE_FILTERING HCI_ULP_ENABLE_DUPLICATE_FILTERING

typedef struct
{
    dm_prim_t       type;            /* DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_ENABLE_REQ */
    phandle_t       phandle;         /* Where to send confirm */
    uint16_t        sync_handle;     /* The train to enable/disable adv reporting */

    /* How to handle periodic advertising reports (Bit defines above).
       bit 0:
           If set then enable the reporting of periodic advertising reports.
       bit 1:
           If set then enable duplicate filtering of periodic advertising reports.
       bit 2-7: Reserved set to 0 */
    uint8_t         enable;
} DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_ENABLE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_ENABLE_CFM
 *---------------------------------------------------------------------------*/
typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_ENABLE_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * Stop being synced to a periodic train. The controller will no longer turn up
 * at periodic advertising intervals once this primitive is sent.
 *
 * RETURNS
 *     DM_ULP_PERIODIC_SCAN_SYNC_TERMINATE_CFM
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;            /* DM_ULP_PERIODIC_SCAN_SYNC_TERMINATE_REQ */
    phandle_t       phandle;         /* Where to send confirm */
    uint16_t        sync_handle;     /* The train to terminate */
} DM_ULP_PERIODIC_SCAN_SYNC_TERMINATE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ULP_PERIODIC_SCAN_SYNC_TERMINATE_CFM
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;               /* DM_ULP_PERIODIC_SCAN_SYNC_TERMINATE_CFM */
    phandle_t       phandle;            /* destination phandle */
    uint8_t         status;             /* Success or failure - See Note1 */
    uint16_t        sync_handle;        /* The train that has been terminated, if success */
} DM_ULP_PERIODIC_SCAN_SYNC_TERMINATE_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     Using the sync handle provided by the local Controller after synchronising
 *     to a periodic advertising train, instruct the Controller to transfer SyncInfo
 *     related to this PA train to a connected peer. This will allow the peer's
 *     Controller to synchronise to the same PA train.
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* Destination phandle */
    TYPED_BD_ADDR_T     addrt;              /* Address of peer device */
    uint16_t            service_data;       /* Service data for peer's Host */
    uint16_t            sync_handle;        /* Identifies sync train to local Controller */
} DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     Confirmation that the local Controller has received the instruction to transfer
 *     SyncInfo to a connected peer. Note that this message does not indicate that
 *     the remote Controller has synchronised successfully to the related PA train.
 *     A status of SUCCESS only indicates that the local Controller has completed the
 *     PAST Link Layer control procedure.
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* Destination phandle */
    uint16_t            sync_handle;        /* Identifies sync train to local Controller */
    uint16_t            status;             /* Success or failure or pending */
} DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     This prim configures how the local Controller will react when SyncInfo
 *     for a periodic advertising train is received from the peer indicated
 *     by the specific BD address.
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* Destination phandle */
    TYPED_BD_ADDR_T     addrt;              /* Address of peer device */
    uint16_t            skip;               /* Number of ads the Controller may skip */
    uint16_t            sync_timeout;       /* Max time between successful ads received */

    /* What to do when SyncInfo is received.
       0 - No attempt is made to synchronise to periodic train.
       1 - Attempt to sync. Send DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_IND on success or
           failure. Do not send periodic advertising reports to application.
       2 - Attempt to sync. Send DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_IND on success or
           failure. Send periodic advertising reports to application on success.
       3 - Attempt to sync. Send DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_IND on success or
           failure. Send periodic advertising reports to application on success and
           enable duplicate filtering. */
    uint8_t             mode;

    /* Specify types of Constant Tone Extension. */
    uint8_t             cte_type;
} DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_PARAMS_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     Confirmation that the local Controller has processed the request to
 *     configure its reaction to incoming SyncInfo transfers for the Peer
 *     device specified.
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t           type;               /* Prim ID */
    phandle_t           phandle;            /* Destination phandle */
    uint16_t            status;             /* Number of ads the Controller may skip */
    TYPED_BD_ADDR_T     addrt;              /* Address of peer device */
} DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_PARAMS_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 * This API allows applications to override the default behavior of the BR/EDR
 * secure connections host support for the indicated BD Address.
 *
 * If host secure connections is enabled by default through DM_SM_INIT_REQ
 * then application can use this API to disable the secure connections
 * for specified BD Address.
 *
 * If host secure connections is not enabled by default then application can
 * use this API to enable the secure connections for specified BD Address.
 *
 * Supported values of host_support_override:
 * 0x00 - Disable secure connection support for provided BD Address
 * 0x01 - Enable secure connection support for provided BD Address
 * 0xFF - Delete the BD Address from the list.
 *
 * If application tries to set BD Address more than the max count that
 * is allowed then status 0x07 (HCI_ERROR_MEMORY_FULL) will be
 * returned through DM_WRITE_SC_HOST_SUPPORT_OVERRIDE_CFM event.
 *
 * RETURNS
 *     DM_WRITE_SC_HOST_SUPPORT_OVERRIDE_CFM_T
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t   type;          /* DM_WRITE_SC_HOST_SUPPORT_OVERRIDE_REQ */
    phandle_t   phandle;       /* destination phandle */
    BD_ADDR_T   bd_addr;       /* BD Address to override */
    uint8_t     host_support_override; /* See above supported values */
} DM_WRITE_SC_HOST_SUPPORT_OVERRIDE_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This event will notify the status of DM_WRITE_SC_HOST_SUPPORT_OVERRIDE_REQ
 * command given by the application.
 * Status value other than zero would imply that the BDADDR was not added to
 * the list.
 *
 * RETURNS
 *     None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;          /* DM_WRITE_SC_HOST_SUPPORT_OVERRIDE_CFM */
    phandle_t       phandle;       /* destination phandle */
    hci_return_t    status;        /* status of set secure connections override */
    BD_ADDR_T       bd_addr;       /* BD Address sent in command */
    uint8_t         host_support_override;  /* override value sent in command */
} DM_WRITE_SC_HOST_SUPPORT_OVERRIDE_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This API allows applications to read the maximum number of supported
 * override BD Address supported in the controller.
 *
 * RETURNS
 *     DM_READ_SC_HOST_SUPPORT_OVERRIDE_MAX_BD_ADDR_CFM_T
 *----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t   type;    /* DM_READ_SC_HOST_SUPPORT_OVERRIDE_MAX_BD_ADDR_REQ */
    phandle_t   phandle; /* destination phandle */
} DM_READ_SC_HOST_SUPPORT_OVERRIDE_MAX_BD_ADDR_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *
 * This event will notify the status of
 * DM_READ_SC_HOST_SUPPORT_OVERRIDE_MAX_BD_ADDR_REQ command given by the
 * application.
 * Status value other than zero is considered to be failure.
 *
 * RETURNS
 *     None
 *----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t       type;     /* DM_READ_SC_HOST_SUPPORT_OVERRIDE_MAX_BD_ADDR_CFM */
    phandle_t       phandle;  /* destination phandle */
    hci_return_t    status;   /* status of set secure connections override */
    uint8_t         max_override_bdaddr; /* Max number of BD Addrs that can be
                                          * supported by local controller */
} DM_READ_SC_HOST_SUPPORT_OVERRIDE_MAX_BD_ADDR_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_REGISTER_REQ primitive is used to register a destination phandle
 *     and reg_context to be used for unicast and broadcast for asynchronous
 *     upstream primitives related to Isochronous functionality.
 *
 *     isoc_type as 0x01 would register for UNICAST
 *     isoc_type as 0x02 would register for BROADCAST
 *     isoc_type as 0x03 would register for both UNICAST and BROADCAST
 *---------------------------------------------------------------------------*/
#define DM_ISOC_TYPE_UNICAST          (uint16_t) 0x01
#define DM_ISOC_TYPE_BROADCAST        (uint16_t) 0x02

typedef struct
{
    dm_prim_t          type;           /* DM_ISOC_REGISTER_REQ */
    phandle_t          phandle;        /* Destination phandle */
    context_t          reg_context;    /* Opaque registration context */
    uint16_t           isoc_type;      /* Type of isochronous for registration */
} DM_ISOC_REGISTER_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_REGISTER_CFM primitive is used to indicate status of the
 *     isochronous registration request.
 *----------------------------------------------------------------------------*/

typedef struct  
{
    dm_prim_t          type;           /* DM_ISOC_REGISTER_CFM */
    phandle_t          phandle;        /* Destination phandle */
    context_t          reg_context;    /* Registration context */
    uint16_t           isoc_type;      /* Type of isochronous registered */
    uint16_t           status;         /* Registration status */
} DM_ISOC_REGISTER_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_BROADCAST_DEVICE_SECURITY_REQ primitive is used to set the device
 *     security mode and level applicable to broadcast a Broadcast Isochronous 
 *     Group (BIG) in an Isochronous Broadcaster or receive a BIS in a 
 *     Synchronized Receiver.
 *---------------------------------------------------------------------------*/
typedef uint8_t dm_isoc_broadcast_sec_level_t;
#define DM_ISOC_BROADCAST_UNENCRYPTED                   (dm_isoc_broadcast_sec_level_t) 0x01
#define DM_ISOC_BROADCAST_ENCRYPTED_UNAUTHENTICATED     (dm_isoc_broadcast_sec_level_t) 0x02
#define DM_ISOC_BROADCAST_ENCRYPTED_AUTHENTICATED       (dm_isoc_broadcast_sec_level_t) 0x03

typedef struct
{
    dm_prim_t                       type;           /* DM_ISOC_BROADCAST_DEVICE_SECURITY_REQ */
    phandle_t                       phandle;        /* Destination phandle */
    dm_isoc_broadcast_sec_level_t   security_level; /* Broadcast security level */
    uint32_t                        info;           /* RFU, shall not be used */
} DM_ISOC_BROADCAST_DEVICE_SECURITY_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_BROADCAST_DEVICE_SECURITY_CFM primitive is used to indicate
 *     the status of DM_ISOC_BROADCAST_DEVICE_SECURITY_REQ request.
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t          type;                        /* DM_ISOC_BROADCAST_DEVICE_SECURITY_CFM */
    phandle_t          phandle;                     /* Destination phandle */
    uint8_t            status;                      /* Success or failure - See Note1 */
    dm_isoc_broadcast_sec_level_t   security_level; /* Broadcast security level set */
} DM_ISOC_BROADCAST_DEVICE_SECURITY_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_CONFIGURE_CIG_REQ primitive is used to configure a CIG. 
 *     On successful configuration of CIG.
 *
 *     Once configuration is successful user will get a cig_id, cis_handle for
 *     each registered CIS. Configured CIG can be re-configured using cig_id if
 *     none of the CISes in the CIG are created. New parameters provided while
 *     re-configuration shall replace the complete set of configured parameters
 *     for the CIG.
 *     
 *     Sleep Clock Accuracy for CIG shall be configured considering worst case
 *     SCA value of all slaves participating in CIG. If application cannot get
 *     the SCA of all the slaves then it shall set the value to zero.
 * 
 *     Note: cis_config shall contain a valid pointer to each CIS that is  
 *     registered under the CIG and it shall be valid for cis_count elements,
 *     rest shall be set to NULL.
 *---------------------------------------------------------------------------*/
#define DM_MAX_SUPPORTED_CIS HCI_CIS_MAX

typedef struct  
{
    uint16_t    max_sdu_m_to_s;             /* Maximum SDU Size from master host */
    uint16_t    max_sdu_s_to_m;             /* Maximum SDU Size from slave host */
    uint8_t     cis_id;                     /* Unique CIS identifier in given cig_id */

    /* PHY from master. If the phy type is DM_ULP_PHY_TYPE_QHS, 
     * the application may choose one of the QHS-rate values DM_ULP_PHY_RATE_QHS_TX_XXXX, 
     * and set the phy_m_to_s accordingly.
     * Ex: phy_m_to_s = (DM_ULP_PHY_TYPE_QHS(bit7) | DM_ULP_PHY_RATE_QHS_TX_XXXX(bit6 to bit4))
     */
    uint8_t     phy_m_to_s;

    /* PHY from slave. If the phy type is DM_ULP_PHY_TYPE_QHS, 
     * the application may choose one of the QHS-rate values DM_ULP_PHY_RATE_QHS_TX_XXXX, 
     * and set the phy_s_to_m accordingly. 
     * Ex: phy_s_to_m = (DM_ULP_PHY_TYPE_QHS(bit7) | DM_ULP_PHY_RATE_QHS_TX_XXXX(bit6 to bit4))
     */
    uint8_t     phy_s_to_m;
    uint8_t     rtn_m_to_s;                 /* Retransmission number from master to slave */
    uint8_t     rtn_s_to_m;                 /* Retransmission number from slave to master */
} DM_CIS_CONFIG_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef struct  
{
    dm_prim_t              type;                /* DM_ISOC_CONFIGURE_CIG_REQ */
    phandle_t              phandle;             /* Destination phandle */
    context_t              context;             /* Config context */
    uint24_t               sdu_interval_m_to_s; /* Time interval between the start of consecutive SDUs */
    uint24_t               sdu_interval_s_to_m; /* Time interval between the start of consecutive SDUs */
    uint16_t               max_transport_latency_m_to_s;   /* Maximum transport latency from master */
    uint16_t               max_transport_latency_s_to_m;   /* Maximum transport latency from slave */
    uint8_t                cig_id;              /* Used to identify the CIG */
    uint8_t                sca;                 /* Sleep clock accuracy */
    uint8_t                packing;             /* Interleaved, Sequential placement of packets */
    uint8_t                framing;             /* Indicates the format: framed or unframed */
    uint8_t                cis_count;           /* Number of CIS under CIG */
    DM_CIS_CONFIG_T        *cis_config[DM_MAX_SUPPORTED_CIS];
                                                /* Array of pointers to cis configuration */
} DM_ISOC_CONFIGURE_CIG_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_CONFIGURE_CIG_CFM primitive is used to indicate status of CIG 
 *     configuration request.
 *     On successful configuration this event will indicate cig_id and
 *     cis_count of valid CIS handles added or modified by the request.
 *     
 *     Note: cis_handles will be arranged in same order as cis is configured.
 *---------------------------------------------------------------------------*/

typedef struct  
{
    dm_prim_t                  type;        /* DM_ISOC_CONFIGURE_CIG_CFM */
    phandle_t                  phandle;     /* Destination phandle */
    context_t                  context;     /* Context received in config req */
    hci_return_t               status;      /* Status of configuration */
    uint8_t                    cig_id;      /* CIG identifier */
    uint8_t                    cis_count;   /* Number of cis configured */
    hci_connection_handle_t    cis_handles[DM_MAX_SUPPORTED_CIS];  
                                            /* CIS handles for cig_id,
                                             * contains cis_count valid elements */
} DM_ISOC_CONFIGURE_CIG_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_CONFIGURE_CIG_TEST_REQ primitive is used to configure a CIG.
 *
 *     Once configuration is successful user will get a cig_id, cis_handle for
 *     each registered CIS. Configured CIG can be re-configured using cig_id if
 *     none of the CISes in the CIG are created. New parameters provided while
 *     re-configuration shall replace the complete set of configured parameters
 *     for the CIG.
 *
 *     Sleep Clock Accuracy for CIG shall be configured considering worst case
 *     SCA value of all slaves participating in CIG. If application cannot get
 *     the SCA of all the slaves then it shall set the value to zero.
 *
 *     Note: cis_config_test shall contain a valid pointer to each CIS that is
 *     registered under the CIG and it shall be valid for cis_count elements,
 *     rest shall be set to NULL.
 *---------------------------------------------------------------------------*/

typedef struct
{
    uint16_t    max_sdu_m_to_s;             /* Maximum SDU Size from master host */
    uint16_t    max_sdu_s_to_m;             /* Maximum SDU Size from slave host */
    uint16_t    max_pdu_m_to_s;             /* Maximum PDU Size from master host */
    uint16_t    max_pdu_s_to_m;             /* Maximum PDU Size from slave host */
    uint8_t     cis_id;                     /* Unique CIS identifier in given cig_id */
    uint8_t     nse;                        /* Max no of sub events for each CIS */
    uint8_t     phy_m_to_s;                 /* PHY from master */
    uint8_t     phy_s_to_m;                 /* PHY from slave */
    uint8_t     bn_m_to_s;                  /* Burst number from master to slave */
    uint8_t     bn_s_to_m;                  /* Burst number from slave to master */
} DM_CIS_CONFIG_TEST_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef struct
{
    dm_prim_t               type;               /* DM_ISOC_CONFIGURE_CIG_TEST_REQ */
    phandle_t               phandle;            /* Destination phandle */
    context_t               context;            /* Config context */
    uint24_t                sdu_interval_m_to_s;/* Time interval between the start of consecutive SDUs */
    uint24_t                sdu_interval_s_to_m;/* Time interval between the start of consecutive SDUs */
    uint16_t                iso_interval;       /* Time b/w two consecutive CIS anchor points */
    uint8_t                 cig_id;             /* Used to identify the CIG */
    uint8_t                 ft_m_to_s;          /* Flush timeout at master side */
    uint8_t                 ft_s_to_m;          /* Flush timeout at slave side */
    uint8_t                 sca;                /* Sleep clock accuracy */
    uint8_t                 packing;            /* Interleaved, Sequential placement of packets */
    uint8_t                 framing;            /* Indicates the format: framed or unframed */
    uint8_t                 cis_count;          /* Number of CIS under CIG */
    DM_CIS_CONFIG_TEST_T    *cis_config_test[DM_MAX_SUPPORTED_CIS];
                                                /* Array of pointers to cis configuration */
} DM_ISOC_CONFIGURE_CIG_TEST_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_CONFIGURE_CIG_TEST_CFM  primitive is used to indicate status of
 *     CIG configuration test request.
 *     On successful configuration this event will indicate cig_id and
 *     cis_count of valid CIS handles added or modified by the request.
 *
 *     Note: cis_handles will be arranged in same order as cis is configured.
 *---------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t                  type;        /* DM_ISOC_CONFIGURE_CIG_TEST_CFM */
    phandle_t                  phandle;     /* Destination phandle */
    context_t                  context;     /* Context received in config req */
    hci_return_t               status;      /* Status of configuration */
    uint8_t                    cig_id;      /* CIG identifier */
    uint8_t                    cis_count;   /* Number of cis configured */
    hci_connection_handle_t    cis_handles[DM_MAX_SUPPORTED_CIS];
                                            /* CIS handles for cig_id,
                                             * contains cis_count valid elements */
} DM_ISOC_CONFIGURE_CIG_TEST_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_REMOVE_CIG_REQ primitive is used to remove the connected
 *     isochronous streams which have previously been configured in the
 *     controller.
 *
 *     If cig_id is not configured already then this primitive will be dropped.
 *
 *     Note: This command should be issued when all Connected Isochronous
 *     Streams in the CIG are disconnected, otherwise user will be notified
 *     with appropriate error code.
 *---------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t              type;                /* DM_ISOC_REMOVE_CIG_REQ */
    uint8_t                cig_id;              /* CIG Identifier to be removed */
} DM_ISOC_REMOVE_CIG_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_REMOVE_CIG_CFM primitive is used to indicate status of
 *     Remove CIG request.
*-----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t                  type;        /* DM_ISOC_REMOVE_CIG_CFM */
    phandle_t                  phandle;     /* Destination phandle */
    context_t                  context;     /* Context recieved in config req */
    hci_return_t               status;      /* Status of configuration */
    uint8_t                    cig_id;      /* Removed CIG Identifier */
} DM_ISOC_REMOVE_CIG_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_CIS_CONNECT_REQ primitive is used to establish connected  
 *     isochronous streams(CIS) with remote device.
 *     
 *     Request can be sent for more than one CIS connection establishment to 
 *     reduce the latency, in such cases DM_ISOC_CIS_CONNECT_CFM is sent from
 *     Bluestack one by one for each successful CIS establishment procedure.
 *     Connection can be requested for up to DM_MAX_SUPPORTED_CIS number of CIS.
 *
 *     Each CIS shall be configured using DM_ISOC_CONFIGURE_CIG_REQ or
 *     DM_ISOC_CONFIGURE_CIG_TEST_REQ before CIS connection establishment
 *     after which reconfiguration will be disallowed.
 *     
 *     Result of CIS establishment is notified using DM_ISOC_CIS_CONNECT_CFM
 *     primitive to the destination phandle.
 *---------------------------------------------------------------------------*/

typedef struct
{
    hci_connection_handle_t    cis_handle;    /* cis handles for isoc connection */
    TP_BD_ADDR_T               tp_addrt;      /* Transport bluetooth device address */
} DM_CIS_CONNECTION_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */
 
typedef struct  
{
    dm_prim_t               type;              /* DM_ISOC_CIS_CONNECT_REQ */
    phandle_t               phandle;           /* Destination phandle */
    context_t               con_context;       /* Connection context */
    uint8_t                 cis_count;         /* Number of CIS connections */
    DM_CIS_CONNECTION_T     *cis_conn[DM_MAX_SUPPORTED_CIS];    
                                               /* List of cis handle and addresses to connect */
} DM_ISOC_CIS_CONNECT_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_CIS_CONNECT_IND primitive is used to indicate remote device's 
 *     attempt to establish connected isochronous streams(CIS).
 *
 *     This primitive will be sent to the destination phandle which is
 *     registered in DM_ISOC_REGISTER_REQ (DM_ISOC_TYPE_UNICAST).
 *
 *     DM_ISOC_CIS_CONNECT_RSP primitive shall be used by the application
 *     to accept or reject incoming connection establishment procedure.
 *---------------------------------------------------------------------------*/

typedef struct  
{
    dm_prim_t                    type;            /* DM_ISOC_CIS_CONNECT_IND */
    phandle_t                    phandle;         /* Destination phandle */
    context_t                    reg_context;     /* Context used in registration */
    TP_BD_ADDR_T                 tp_addrt;        /* Transport bd address of remote device */
    hci_connection_handle_t      cis_handle;      /* CIS handle */
    uint8_t                      cig_id;          /* CIG Id received from remote device */
    uint8_t                      cis_id;          /* CIS Id received from remote device */
} DM_ISOC_CIS_CONNECT_IND_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_CIS_CONNECT_RSP primitive is used to accept or reject the CIS 
 *     connection initiation from remote device.
 *
 *     CIS handle is used to identity CIS connection to accept or reject 
 *     establishment with hci error code.
 * 
 *     Result of CIS establishment is notified using DM_ISOC_CIS_CONNECT_CFM
 *     primitive to the destination phandle.
 *---------------------------------------------------------------------------*/

typedef struct  
{
    dm_prim_t                  type;              /* DM_ISOC_CIS_CONNECT_RSP */
    phandle_t                  phandle;           /* Destination phandle */
    context_t                  con_context;       /* Connection context */
    hci_connection_handle_t    cis_handle;        /* CIS handle from connect ind */
    hci_return_t               status;            /* HCI status */
} DM_ISOC_CIS_CONNECT_RSP_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_CIS_CONNECT_CFM primitive is used to indicate the result of 
 *     individual CIS connection establishment. 
 *     
 *     cis_params are the controller agreed parameters with the peer during
 *     the cis establishment.
  *---------------------------------------------------------------------------*/

typedef struct
{
    uint24_t cig_sync_delay;
    uint24_t cis_sync_delay;
    uint24_t transport_latency_m_to_s;
    uint24_t transport_latency_s_to_m;
    uint16_t max_pdu_m_to_s;
    uint16_t max_pdu_s_to_m;
    uint16_t iso_interval;
    uint8_t  phy_m_to_s;
    uint8_t  phy_s_to_m;
    uint8_t  nse;
    uint8_t  bn_m_to_s;
    uint8_t  bn_s_to_m;
    uint8_t  ft_m_to_s;
    uint8_t  ft_s_to_m;
    
    /* TRUE value indicates the presence of additional v2 (HCI_LE_CIS_Established) parameters */
    bool_t   extented_v2_param;
 
    /* Additional version 2 parameters */
    uint24_t sub_interval;
    uint24_t sdu_interval_c_to_p;
    uint24_t sdu_interval_p_to_c;
    uint16_t max_sdu_c_to_p;
    uint16_t max_sdu_p_to_c;
    uint8_t  framing;
}DM_CIS_PARAM_T;

typedef struct  
{
    dm_prim_t                  type;       /* DM_ISOC_CIS_CONNECT_CFM */
    phandle_t                  phandle;    /* Destination phandle */
    context_t                  con_context;/* Connection context */
    TP_BD_ADDR_T               tp_addr;    /* Transport bluetooth device address */
    hci_connection_handle_t    cis_handle; /* CIS handle for cis establishment */
    hci_return_t               status;     /* HCI status */
    DM_CIS_PARAM_T             cis_params; /* CIS parameters agreed during cis establishment */
} DM_ISOC_CIS_CONNECT_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_CIS_DISCONNECT_REQ primitive is used to terminate CIS connection
 *     
 *     For the provided cis_handle if the connection context was not created,
 *     then this primitive will be dropped. Typically connection context will
 *     be created using the primitives DM_ISOC_CIS_CONNECT_REQ and
 *     DM_ISOC_CIS_CONNECT_RSP.
 *
 *     CIS connection can be disconnected using cis_handle and appropriate HCI 
 *     reason code for disconnection.
 *---------------------------------------------------------------------------*/
 
typedef struct  
{
    dm_prim_t                  type;          /* DM_ISOC_CIS_DISCONNECT_REQ */
    hci_connection_handle_t    cis_handle;    /* CIS handle for disconnection */
    hci_reason_t               reason;        /* Reason for command */
} DM_ISOC_CIS_DISCONNECT_REQ_T;                

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_CIS_DISCONNECT_CFM primitive is used to indicate the CIS
 *     disconnect request status.
 *---------------------------------------------------------------------------*/

typedef struct  
{
    dm_prim_t                  type;          /* DM_ISOC_CIS_DISCONNECT_CFM */
    phandle_t                  phandle;       /* Destination phandle */
    context_t                  con_context;   /* Connection context */
    hci_connection_handle_t    cis_handle;    /* CIS handle for disconnection */
    hci_return_t               status;        /* HCI status */
} DM_ISOC_CIS_DISCONNECT_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_CIS_DISCONNECT_IND primitive is used to indicate that CIS  
 *     connection has been terminated.
 *---------------------------------------------------------------------------*/
typedef struct  
{
    dm_prim_t                  type;          /* DM_ISOC_CIS_DISCONNECT_IND */
    phandle_t                  phandle;       /* Destination phandle */
    context_t                  con_context;   /* Connection context */
    hci_connection_handle_t    cis_handle;    /* CIS handle for disconnection */
    hci_error_t                reason;        /* HCI status */
} DM_ISOC_CIS_DISCONNECT_IND_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_CREATE_BIG_REQ primitive is used to create BIG with one or more
 *     BISes. All BISes in the BIG will have the same parameter values.
 *
 *     Broadcast code parameter is used to encrypt the BIS payloads.
 *     If the Encryption parameter is set to 0 (unecrypted), then the
 *     16 byte Broadcast_Code shall be zeroed and ignored by bluestack.
 *
 *     Once BIG create is successful user will be notified with bis connection
 *     handles for all BISes through DM_ISOC_CREATE_BIG_CFM.
 *     If controller cannot create the requested BISes then user will be
 *     notified with appropriate error code.
 *---------------------------------------------------------------------------*/

/* 16(0x10) octets broadcast code will be used to encrypt and decrypt
 * the BIS payloads. */
#define DM_BROADCAST_CODE_SIZE     HCI_ULP_BROADCAST_CODE_SIZE

/* Broadcast encryption mode */
#define DM_ISOC_BROADCAST_UNENCRYPTED_DATA                  (uint8_t) 0x00
#define DM_ISOC_BROADCAST_ENCRYPTED_UNAUTHENTICATED_DATA    (uint8_t) 0x01
#define DM_ISOC_BROADCAST_ENCRYPTED_AUTHENTICATED_DATA      (uint8_t) 0x81

typedef struct
{
    uint24_t    sdu_interval;           /* Interval of Periodic SDUs*/
    uint16_t    max_sdu;                /* Maximum size of an SDU */
    uint16_t    max_transport_latency;  /* Max transport latency */
    uint8_t     rtn;                    /* Retransmission number */

    /* Preferred PHY for transmission. If the phy type is DM_ULP_PHY_TYPE_QHS, 
     * the application may choose one of the QHS-rate values DM_ULP_PHY_RATE_QHS_TX_XXXX, 
     * and set the phy accordingly.
     * Ex: phy = (DM_ULP_PHY_TYPE_QHS | DM_ULP_PHY_RATE_QHS_TX_XXXX)
     */
    uint8_t     phy;
    uint8_t     packing;                /* Sequential or Interleaved */
    uint8_t     framing;                /* Framed or Unframed */
} DM_BIG_CONFIG_PARAM_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef struct
{
    dm_prim_t               type;           /* DM_ISOC_CREATE_BIG_REQ */
    phandle_t               phandle;        /* Destination phandle */
    context_t               con_context;    /* Connection context */
    DM_BIG_CONFIG_PARAM_T   big_config;     /* Big Params */
    uint8_t                 big_handle;     /* Host identifier of BIG */
    uint8_t                 adv_handle;     /* Handle associated with PA */
    uint8_t                 num_bis;        /* Total number of BISes in BIG */
    uint8_t                 encryption;     /* Refer Broadcast encryption mode defines above */
    uint8_t                 broadcast_code[DM_BROADCAST_CODE_SIZE];
                                      /* Broadcast code to enc BIS payloads */
} DM_ISOC_CREATE_BIG_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_CREATE_BIG_TEST_REQ primitive is used to create BIG with one or more
 *     BISes. All BISes in the BIG will have the same parameter values.
 *
 *     Note: Should be used only for test purposes.
 *
 *     Broadcast code parameter is used to encrypt the BIS payloads.
 *     If the Encryption parameter is set to 0 (unecrypted), then the
 *     16 byte Broadcast_Code shall be zeroed and ignored by bluestack.
 *
 *     Once BIG create is successful user will be notified with bis connection
 *     handles for all BISes through DM_ISOC_CREATE_BIG_TEST_CFM.
 *     If controller cannot create the requested BISes then user will be
 *     notified with appropriate error code.
 *---------------------------------------------------------------------------*/
typedef struct
{
    uint24_t                 sdu_interval;  /* Interval of Periodic SDUs*/
    uint16_t                 iso_interval;  
                 /* Time between consecutive BIG anchor points */
    uint8_t                  nse; 
                 /* Total number of subevents for each BIS in BIG event */
    uint16_t                 max_sdu;  /* Maximum size of an SDU */
    uint16_t                 max_pdu;  /* Maximum size of payload */
    uint8_t                  phy;      /* Preferred PHY for transmission */
    uint8_t                  packing;  /* Sequential or Interleaved */
    uint8_t                  framing;  /* Framed or Unframed */
    uint8_t                  bn;            
                 /* Number of new payloads in each interval of BIS */
    uint8_t                  irc;
                 /* Total number of times scheduled payloads are transmitted */
    uint8_t                  pto;      /* Offsets used for pre-transmissions */
} DM_BIG_TEST_CONFIG_PARAM_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef struct
{
    dm_prim_t                   type;           /* DM_ISOC_CREATE_BIG_TEST_REQ */
    phandle_t                   phandle;        /* Destination phandle */
    context_t                   con_context;    /* Connection context */
    DM_BIG_TEST_CONFIG_PARAM_T  big_config;     /* Big Params */
    uint8_t                     big_handle;     /* Host identifier of BIG */
    uint8_t                     adv_handle;     /* Handle associated with PA */
    uint8_t                     num_bis;        /* Total number of BISes in BIG */
    uint8_t                     encryption;     /* Refer Broadcast encryption mode defines above */
    uint8_t                     broadcast_code[DM_BROADCAST_CODE_SIZE];
                                      /* Broadcast code to enc BIS payloads */
} DM_ISOC_CREATE_BIG_TEST_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_CREATE_BIG_CFM primitive is used to indicate the BIG create
 *     request status.
 *
 *     The return parameters are the controller agreed parameters and
 *     these parameters shall not change during the lifetime of the BIG.
 *
 *     Note: Paramter 'type' will be DM_ISOC_CREATE_BIG_CFM.
 *---------------------------------------------------------------------------*/

typedef struct
{
    uint24_t        transport_latency_big;/* Max time to tx SDUs of all BISes */
    uint16_t        max_pdu;              /* Maximum size of an PDU */
    uint16_t        iso_interval;         /* ISO interval */
    uint8_t         phy;                  /* PHY used */
    uint8_t         nse;                  /* Number of sub events */
    uint8_t         bn;                   /* Burst number */
    uint8_t         pto;                  /* Pre transmission offset */
    uint8_t         irc;                  /* Repeated count of retransmission */
} DM_BIG_PARAM_T; /* autogen_makefile_ignore_this (DO NOT REMOVE THIS COMMENT) */

typedef struct
{
    dm_prim_t                type;          /* DM_ISOC_CREATE_BIG_CFM */
    phandle_t                phandle;       /* Destination phandle */
    context_t                con_context;   /* Connection context */
    uint24_t                 big_sync_delay;/* Max time to tx PDUs of all BISes */
    DM_BIG_PARAM_T           big_params;    /* Confirmed Big Parameters */
    uint8_t                  big_handle;    /* Host identifier of BIG */
    hci_return_t             status;        /* HCI status */
    uint8_t                  num_bis;       /* Number of BISes in BIG */
    hci_connection_handle_t  *bis_handles;  /* Connection handle of BISes */
} DM_ISOC_CREATE_BIG_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_CREATE_BIG_TEST_CFM primitive is used to indicate the BIG create
 *     test request status.
 *
 *     The return parameters are the controller agreed parameters and
 *     these parameters shall not change during the lifetime of the BIG.
 *
 *     Note: Paramter 'type' will be DM_ISOC_CREATE_BIG_TEST_CFM.
 *---------------------------------------------------------------------------*/
typedef DM_ISOC_CREATE_BIG_CFM_T DM_ISOC_CREATE_BIG_TEST_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_TERMINATE_BIG_REQ primitive is used to terminate BIG identified
 *     by the big_handle.
 *
 *     For the provided big_handle if the connection context was not created,
 *     then this primitive will be dropped. Typically connection context will
 *     be created using the primitive DM_ISOC_CREATE_BIG_REQ or 
 *     DM_ISOC_CREATE_BIG_TEST_REQ.
 *
 *     This command also terminates the transmission of all BISes of the BIG
 *     and destroys associated connection handles of the BISes in BIG.
 *---------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t                type;          /* DM_ISOC_TERMINATE_BIG_REQ */
    uint8_t                  big_handle;    /* Host identifier of BIG */
    hci_reason_t             reason;        /* Reason for BIG termination */
} DM_ISOC_TERMINATE_BIG_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_TERMINATE_BIG_CFM primitive is used to indicate the BIG
 *     termination request status.
 *---------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t                type;              /* DM_ISOC_TERMINATE_BIG_CFM */
    phandle_t                phandle;           /* Destination phandle */
    context_t                con_context;       /* Connection context */
    uint8_t                  big_handle;        /* Host identifier of BIG */
    hci_return_t             status_or_reason;  /* Status */
} DM_ISOC_TERMINATE_BIG_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_BIG_CREATE_SYNC_REQ primitive is used to synchronize to a BIG
 *     reported in DM_HCI_ULP_BIGINFO_ADV_REPORT_IND.
 *
 *     Broadcast code parameter is used to encrypt the BIS payloads.
 *     If the Encryption parameter is set to 0 (unecrypted), then the
 *     16 byte Broadcast_Code shall be zeroed and ignored by bluestack.
 *
 *     Once BIG create sync is established user will be notified with bis
 *     connection handles for all BISes through DM_ISOC_BIG_CREATE_SYNC_CFM in
 *     the same order of the BIS indices.
 *
 *     Note: The list of BIS indices shall be in ascending order and shall not
 *     contain any duplicates. The list of BISes may be all or subset of BISes
 *     available in the BIG.
 *
 *     If controller cannot create the requested BISes then user will be
 *     notified with appropriate error code.
 *
 *---------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t       type;               /* DM_ISOC_BIG_CREATE_SYNC_REQ */
    phandle_t       phandle;            /* Destination phandle */
    context_t       con_context;        /* Connection context */
    uint16_t        sync_handle;        /* Sync handle of the PA */
    uint16_t        big_sync_timeout;   /* Sync timeout of BIS PDUs */
    uint8_t         big_handle;         /* Host identifier of BIG */
    uint8_t         mse;                /* Maximum sub events */
    uint8_t         encryption;         /* Refer Broadcast encryption mode defines above */
    uint8_t         broadcast_code[DM_BROADCAST_CODE_SIZE];
                          /* Broadcast code to encrypt or decrypt BIS payloads*/
    uint8_t         num_bis;            /* Num of BISes requested */
    uint8_t         *bis;               /* Indices corresponding to BISes */
} DM_ISOC_BIG_CREATE_SYNC_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_BIG_CREATE_SYNC_CFM primitive is used to indicate the CIS
 *     disconnect request status.
 *
 *     The phy parameter in DM_BIG_PARAM_T shall be ignored by the application.
 *
 *     Note: The order of the BIS connection handles can be mapped to
 *     the BIS indices sent in the request.
 *---------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t                type;          /* DM_ISOC_BIG_CREATE_SYNC_CFM */
    phandle_t                phandle;       /* Destination phandle */
    context_t                con_context;   /* Connection context */
    DM_BIG_PARAM_T           big_params;    /* Confirmed Big Parameters */
    uint8_t                  big_handle;    /* Host identifier of BIG */
    hci_return_t             status;        /* HCI status */
    uint8_t                  num_bis;       /* Number of BISes synchronized */
    hci_connection_handle_t  *bis_handles;  /* Connection handle of BISes */
} DM_ISOC_BIG_CREATE_SYNC_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_BIG_TERMINATE_SYNC_REQ primitive is used to stop synchronizing
 *     or cancel the process of synchronizing to the BIG.
 *
 *     This command also terminates the reception of all BISes of the BIG
 *     and destroys associated connection handles of the BISes in BIG.
 *
 *     For the provided big_handle if the connection context was not created,
 *     then this primitive will be dropped. Typically connection context will
 *     be created using the primitive DM_ISOC_BIG_CREATE_SYNC_REQ.
 *
 *     User will be notified the status of this command through
 *     DM_ISOC_BIG_TERMINATE_SYNC_IND.
 *---------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t                type;          /* DM_ISOC_BIG_TERMINATE_SYNC_REQ */
    uint8_t                  big_handle;    /* Host identifier of BIG */
} DM_ISOC_BIG_TERMINATE_SYNC_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_BIG_TERMINATE_SYNC_IND primitive is used to indicate the
 *     either status of DM_ISOC_BIG_TERMINATE_SYNC_REQ or The BIG has been
 *     terminated by the remote device or sync lost with remote device.
 *---------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t                type;          /* DM_ISOC_BIG_TERMINATE_SYNC_IND */
    phandle_t                phandle;       /* Destination phandle */
    context_t                con_context;   /* Connection context */
    uint8_t                  big_handle;    /* Host identifier of BIG */
    hci_return_t             status_or_reason; /* status*/
} DM_ISOC_BIG_TERMINATE_SYNC_IND_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_HCI_ULP_BIGINFO_ADV_REPORT_IND primitive is used to report BIGInfo
 *     field of the Broadcaster. User can synchronize to the broadcaster BIG
 *     using the BIGInfo received in the report indication.
 *
 *     Encryption parameter tells the BIS payloads are encrypted or not. If
 *     encrypted, User has to provide Broadcast code (Bluetooth Privacy Code)
 *     in the DM_ISOC_BIG_CREATE_SYNC_REQ to decrypt the BIS payloads.
 *
 *     The transport_latency_big parameter in DM_BIG_PARAM_T shall be ignored
 *     by the application.
 *
 *---------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t           type;          /* DM_HCI_ULP_BIGINFO_ADV_REPORT_IND */
    phandle_t           phandle;       /* Destination phandle */
    context_t           reg_context;   /* Register context */
    DM_BIG_PARAM_T      big_params;    /* Big params from peer s*/
    uint24_t            sdu_interval;  /* Interval of Periodic SDUs*/
    uint16_t            sync_handle;   /* Sync handle of the PA */
    uint16_t            max_sdu;       /* Maximum size of an SDU */
    uint8_t             num_bis;       /* Number of BISes in BIG */
    uint8_t             framing;       /* Framed or unframed data */
    uint8_t             encryption;    /* Data encryption status */
} DM_HCI_ULP_BIGINFO_ADV_REPORT_IND_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_SETUP_ISO_DATA_PATH_REQ primitive is used to setup the
 *     ISOC over HCI transport or vendor specific transport for the
 *     data path direction for CIS or BIS.
 *
 *     Data_path_id when set to zero, the data_path shall be over HCI transport.

 *     Data path direction specifies the direction of data from or to controller.
 *     User has to send this command twice to setup the data path
 *     0x00 Input (Host to Controller) and
 *     0x01 Output (Controller to Host).
 *
 *     Refer to HCI_DATA_PATH_* for vendor specific data path IDs

 *     Maximum size of codec_config_data allowed is HCI_CODEC_CONFIG_DATA_LENGTH.
 *
 *     For the provided cis/bis handle if the connection context was not created,
 *     then this primitive will be dropped.
 *---------------------------------------------------------------------------*/
#define DM_CODEC_ID_OCTETS_SIZE     HCI_CODEC_ID_OCTETS_SIZE

typedef struct
{
    dm_prim_t               type;          /* DM_ISOC_SETUP_ISO_DATA_PATH_REQ */
    uint24_t                controller_delay;
    hci_connection_handle_t handle;        /* CIS or BIS handle */
    uint8_t                 data_path_direction;
    uint8_t                 data_path_id; /* Vendor specific data path IDs*/
    uint8_t                 codec_id[DM_CODEC_ID_OCTETS_SIZE];
    uint8_t                 codec_config_length; /* Codec config data length */
    /* Array of pointers containing codec config data,
     * Users shall pack the data using
     *     HCI_CODEC_CONFIG_DATA_PER_PTR - bytes in a pointer at block.
     *     HCI_CODEC_CONFIG_DATA_PTRS - Number of pointer blocks. */
    uint8_t                 *codec_config_data[HCI_CODEC_CONFIG_DATA_PTRS];
}  DM_ISOC_SETUP_ISO_DATA_PATH_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_SETUP_ISO_DATA_PATH_CFM primitive is used to indicate the Setup
 *     ISO data path request status.
 *---------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t                  type;          /* DM_ISOC_SETUP_ISO_DATA_PATH_CFM */
    phandle_t                  phandle;       /* Destination phandle*/
    context_t                  con_context;   /* Connection context */
    hci_connection_handle_t    handle;        /* CIS or BIS handle */
    hci_return_t               status;        /* HCI status */
}DM_ISOC_SETUP_ISO_DATA_PATH_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_REMOVE_ISO_DATA_PATH_REQ primitive is used to remove the ISO
 *     data path associated with CIS or BIS.
 *
 *     For the provided cis/bis handle if the connection context was not created,
 *     then this primitive will be dropped.
 *---------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t                  type;          /* DM_ISOC_REMOVE_ISO_DATA_PATH_REQ */
    hci_connection_handle_t    handle;        /* CIS or BIS handle */
    uint8_t                    data_path_direction; /* Direction of the path to be removed */
} DM_ISOC_REMOVE_ISO_DATA_PATH_REQ_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_REMOVE_ISO_DATA_PATH_CFM primitive is used to indicate the Remove
 *     ISO data path request status.
 *---------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t                  type;          /* DM_ISOC_REMOVE_ISO_DATA_PATH_CFM */
    phandle_t                  phandle;       /* Destination phandle */
    context_t                  con_context;   /* Connection context */
    hci_connection_handle_t    handle;        /* CIS or BIS handle */
    hci_return_t               status;        /* HCI status */
} DM_ISOC_REMOVE_ISO_DATA_PATH_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_ISO_TRANSMIT_TEST_REQ and DM_ISOC_ISO_TRANSMIT_TEST_CFM
 *     primitive is used to generate and send the ISOC data
 *     from the controller
*-----------------------------------------------------------------------------*/

typedef struct
{
    dm_prim_t                  type;        /* DM_ISOC_ISO_TRANSMIT_TEST_REQ */
    hci_connection_handle_t    handle;      /* cis or bis handle for isoc connection */
    uint8_t                    payload_type;
} DM_ISOC_ISO_TRANSMIT_TEST_REQ_T;

typedef struct
{
    dm_prim_t                  type;        /* DM_ISOC_ISO_TRANSMIT_TEST_CFM */
    phandle_t                  phandle;     /* destination phandle */
    context_t                  con_context; /* connection context */
    uint8_t                    status;      /* status of configuration */
    hci_connection_handle_t    handle;      /* cis or bis handle for isoc connection */
} DM_ISOC_ISO_TRANSMIT_TEST_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_ISO_RECEIVE_TEST_REQ  adn DM_ISOC_ISO_RECEIVE_TEST_CFM
 *     primitive is used to receive the ISOC data
 *     in the controller and discard
*-----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t                  type;        /* DM_ISOC_ISO_RECEIVE_TEST_REQ */
    hci_connection_handle_t    handle;      /* cis or bis handle for isoc connection */
    uint8_t                    payload_type;
} DM_ISOC_ISO_RECEIVE_TEST_REQ_T;


typedef struct
{
    dm_prim_t                  type;        /* DM_ISOC_ISO_RECEIVE_TEST_CFM */
    phandle_t                  phandle;     /* destination phandle */
    context_t                  con_context; /* connection context */
    uint8_t                    status;      /* status of configuration */
    hci_connection_handle_t    handle;      /* cis or bis handle for isoc connection */
} DM_ISOC_ISO_RECEIVE_TEST_CFM_T;


/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_ISO_READ_TEST_COUNTERS_REQ primitive is used to read
 *     the test counters of the received ISO data packets in the controller.
*-----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t                  type;        /* DM_ISOC_ISO_READ_TEST_COUNTERS_REQ */
    hci_connection_handle_t    handle;      /* cis or bis handle for isoc connection */
} DM_ISOC_ISO_READ_TEST_COUNTERS_REQ_T;


typedef struct
{
    dm_prim_t                  type;        /* DM_ISOC_ISO_READ_TEST_COUNTERS_CFM */
    phandle_t                  phandle;     /* destination phandle */
    context_t                  con_context; /* connection context */
    uint8_t                    status;      /* status of configuration */
    hci_connection_handle_t    handle;      /* cis or bis handle for isoc connection */
    uint32_t                   received_packet_count;
    uint32_t                   missed_packet_count;
    uint32_t                   failed_packet_count;
} DM_ISOC_ISO_READ_TEST_COUNTERS_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_ISOC_READ_ISO_LINK_QUALITY_REQ primitive is used to read the 
 *     counters related to the link quality that are associated 
 *     with the isochronous stream in the controller.
*-----------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t                  type;        /* DM_ISOC_READ_ISO_LINK_QUALITY_REQ */
    hci_connection_handle_t    handle;      /* cis or bis handle for isoc connection */
} DM_ISOC_READ_ISO_LINK_QUALITY_REQ_T;

typedef struct
{
    dm_prim_t                  type;        /* DM_ISOC_READ_ISO_LINK_QUALITY_CFM */
    phandle_t                  phandle;     /* destination phandle */
    context_t                  con_context; /* connection context */
    uint8_t                    status;      /* status of configuration */
    hci_connection_handle_t    handle;      /* cis or bis handle for isoc connection */
    uint32_t                   tx_unacked_packets;
    uint32_t                   tx_flushed_packets;
    uint32_t                   tx_last_subevent_packets;
    uint32_t                   retransmitted_packets;
    uint32_t                   crc_error_packets;
    uint32_t                   rx_unreceived_packets;
    uint32_t                   duplicate_packets;
} DM_ISOC_READ_ISO_LINK_QUALITY_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_HCI_ULP_SET_DEFAULT_SUBRATE_REQ primitive is used to set the
 *     acceptable parameters for the subrate requests 
 *     (DM_HCI_ULP_SUBRATE_CHANGE_REQ) sent from Peripheral for all future 
 *     LE ACL connection at the Central.
 *
 *     Note that this primitive does not affect the existing connections.
 *
 *     DM_HCI_ULP_SET_DEFAULT_SUBRATE_CFM will be sent in response to this 
 *     primitive.
 *---------------------------------------------------------------------------*/

typedef HCI_ULP_SET_DEFAULT_SUBRATE_T DM_HCI_ULP_SET_DEFAULT_SUBRATE_REQ_T;

typedef DM_HCI_STANDARD_COMMAND_CFM_T DM_HCI_ULP_SET_DEFAULT_SUBRATE_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_HCI_ULP_SUBRATE_CHANGE_REQ primitive is used by Central or Peripheral 
 *     to change the subrate factor or other connection parameters to an 
 *     existing connection.
 *
 *     DM_HCI_ULP_SUBRATE_CHANGE_CFM will be sent in response to this 
 *     primitive.
 *
 *     DM_HCI_ULP_SUBRATE_CHANGE_IND will be sent once the subrate update is 
 *     completed with the updated parameters.
 *---------------------------------------------------------------------------*/

typedef HCI_ULP_SUBRATE_REQUEST_T DM_HCI_ULP_SUBRATE_CHANGE_REQ_T;

typedef struct
{
    dm_prim_t           type;     /* DM_HCI_ULP_SUBRATE_CHANGE_CFM */
    phandle_t           phandle;  /* destination phandle */
    uint8_t             status;   /* status of the configuration */
    TYPED_BD_ADDR_T     addrt;    /* peer device address */
} DM_HCI_ULP_SUBRATE_CHANGE_CFM_T;

/*----------------------------------------------------------------------------*
 * PURPOSE
 *     DM_HCI_ULP_SUBRATE_CHANGE_IND primitive will be sent whenever 
 *     DM_HCI_ULP_SUBRATE_CHANGE_REQ is sent successfully from host or 
 *     DM_HCI_ULP_SUBRATE_CHANGE_IND primitive will be sent whenever subrate or
 *     other connection parameters are updated following a request from the 
 *     peer device.
 *
 *     DM_HCI_ULP_SUBRATE_CHANGE_IND will not be sent if no parameters are 
 *     updated following a request from peer device.
 *---------------------------------------------------------------------------*/
typedef struct
{
    dm_prim_t                type;                /* DM_HCI_ULP_SUBRATE_CHANGE_IND */
    phandle_t                phandle;             /* destination phandle */
    uint8_t                  status;              /* status of the configuration */
    TYPED_BD_ADDR_T          addrt;               /* peer device address */
    uint16_t                 subrate_factor;      /* New subrate factor applied */
    /* New peripheral latency in number of subrated connection events */
    uint16_t                 peripheral_latency;  
    /* Number of underlying connection events to remain active */
    uint16_t                 continuation_num;
    /* New supervision timeout for the connection */
    uint16_t                 supervision_timeout;
} DM_HCI_ULP_SUBRATE_CHANGE_IND_T;

/*------------------------------------------------------------------------
 *
 *      UNION OF       PRIMITIVES
 *
 *-----------------------------------------------------------------------*/
typedef union
{
    dm_prim_t                                               type;
    DM_COMMON_T                                             dm_common;
    DM_COMMON_RSP_T                                         dm_common_rsp;
    HCI_COMMAND_COMMON_T                                    dm_hci_common;
    HCI_WITH_CH_COMMON_T                                    dm_hci_with_handle;
    HCI_ULP_WITH_CH_COMMON_T                                dm_hci_ulp_with_handle;
    HCI_WITH_CH_PT_COMMON_T                                 dm_hci_cmd_with_handle_trnsprt;
    HCI_ULP_WITH_ADV_HANDLE_T                               dm_hci_ulp_with_adv_handle;
    DM_UPSTREAM_COMMON_T                                    dm_upstream_common;
    DM_UPSTREAM_BD_ADDR_COMMON_T                            dm_upstream_bd_addr_common;
    DM_UPSTREAM_TYPED_BD_ADDR_COMMON_T                      dm_upstream_typed_bd_addr_common;
    DM_HCI_STANDARD_COMMAND_CFM_T                           dm_standard_command_cfm;
    DM_HCI_BD_ADDR_COMMAND_CFM_T                            dm_bd_addr_command_cfm;
    DM_HCI_TYPED_BD_ADDR_COMMAND_CFM_T                      dm_typed_bd_addr_command_cfm;
    DM_HCI_TYPED_BD_ADDR_PT_COMMAND_CFM_T                   dm_typed_bd_addr_pt_command_cfm;
    DM_SYNC_UPSTREAM_WITH_HANDLE_COMMON_T                   dm_sync_upstream_with_handle_common;
    DM_SYNC_DOWNSTREAM_WITH_HANDLE_COMMON_T                 dm_sync_downstream_with_handle_common;

    DM_CONTROLLER_READY_NTF_T                               dm_controller_ready_ntf;

    DM_ACL_CLOSED_IND_T                                     dm_acl_closed_ind;
    DM_ACL_CLOSE_REQ_T                                      dm_acl_close_req;
    DM_ACL_CLOSE_CFM_T                                      dm_acl_close_cfm;
    DM_ACL_OPEN_CFM_T                                       dm_acl_open_cfm;
    DM_ACL_OPENED_IND_T                                     dm_acl_opened_ind;
    DM_ACL_OPEN_REQ_T                                       dm_acl_open_req;

    DM_AM_REGISTER_CFM_T                                    dm_am_register_cfm;
    DM_AM_REGISTER_REQ_T                                    dm_am_register_req;
    DM_AM_REGISTER_WRONG_API_CFM_T                          dm_am_register_wrong_api_cfm;
    DM_AM_REGISTER_WRONG_API_REQ_T                          dm_am_register_wrong_api_req;


    DM_AMPM_REGISTER_REQ_T                                  dm_ampm_register_req;
    DM_AMPM_CONNECT_RSP_T                                   dm_ampm_connect_rsp;
    DM_AMPM_CONNECT_CHANNEL_RSP_T                           dm_ampm_connect_channel_rsp;
    DM_AMPM_DISCONNECT_CHANNEL_RSP_T                        dm_ampm_disconnect_channel_rsp;
    DM_AMPM_DISCONNECT_REQ_T                                dm_ampm_disconnect_req;
    DM_AMPM_READ_BD_ADDR_REQ_T                              dm_ampm_read_bd_addr_req;
    DM_AMPM_VERIFY_PHYSICAL_LINK_RSP_T                      dm_ampm_verify_physical_link_rsp;
    DM_AMPM_READ_DATA_BLOCK_SIZE_RSP_T                      dm_ampm_read_data_block_size_rsp;
    DM_AMPM_NUMBER_COMPLETED_DATA_BLOCKS_REQ_T              dm_ampm_number_completed_data_blocks_req;

    DM_AMPM_REGISTER_CFM_T                                  dm_ampm_register_cfm;
    DM_AMPM_CONNECT_IND_T                                   dm_ampm_connect_ind;
    DM_AMPM_CONNECT_CHANNEL_IND_T                           dm_ampm_connect_channel_ind;
    DM_AMPM_DISCONNECT_CHANNEL_IND_T                        dm_ampm_disconnect_channel_ind;
    DM_AMPM_LINK_KEY_NOTIFICATION_IND_T                     dm_ampm_link_key_notification_ind;
    DM_AMPM_READ_BD_ADDR_CFM_T                              dm_ampm_read_bd_addr_cfm;
    DM_AMPM_VERIFY_PHYSICAL_LINK_IND_T                      dm_ampm_verify_physical_link_ind;
    DM_AMPM_READ_DATA_BLOCK_SIZE_IND_T                      dm_ampm_read_data_block_size_ind;
    DM_AMPM_SIMPLE_PAIRING_ENABLED_IND_T                    dm_ampm_simple_pairing_enabled_ind;
    DM_AMPM_REMOTE_FEATURES_IND_T                           dm_ampm_remote_features_ind;

    DM_BAD_MESSAGE_IND_T                                    dm_bad_message_ind;
    DM_BLUESTACK_STATE_TRANSITION_ENTRY_IND_T               dm_bluestack_state_transition_entry_ind;
    DM_BLUESTACK_STATE_TRANSITION_EXIT_IND_T                dm_bluestack_state_transition_exit_ind;

    DM_CLEAR_PARAM_CACHE_CFM_T                              dm_clear_param_cache_cfm;
    DM_CLEAR_PARAM_CACHE_REQ_T                              dm_clear_param_cache_req;

    DM_DATA_FROM_HCI_REQ_T                                  dm_data_from_hci_req;
    DM_DATA_TO_HCI_IND_T                                    dm_data_to_hci_ind;

    DM_HCI_CHANGE_CONN_LINK_KEY_REQ_T                       dm_change_link_key_req;
    DM_HCI_CHANGE_LOCAL_NAME_CFM_T                          dm_change_local_name_cfm;
    DM_HCI_CHANGE_LOCAL_NAME_REQ_T                          dm_change_local_name_req;
    DM_HCI_CHANGE_CONN_PKT_TYPE_REQ_T                       dm_change_packet_type_req;
    DM_HCI_CONN_PACKET_TYPE_CHANGED_IND_T                   dm_conn_packet_type_changed_ind;
    DM_HCI_CREATE_CONNECTION_CANCEL_CFM_T                   dm_create_connection_cancel_cfm;
    DM_HCI_CREATE_CONNECTION_CANCEL_REQ_T                   dm_create_connection_cancel_req;
    DM_HCI_DELETE_STORED_LINK_KEY_CFM_T                     dm_delete_stored_link_key_cfm;
    DM_HCI_DELETE_STORED_LINK_KEY_REQ_T                     dm_delete_stored_link_key_req;
    DM_HCI_ENABLE_DUT_MODE_CFM_T                            dm_enable_device_ut_mode_cfm;
    DM_HCI_ENABLE_DUT_MODE_REQ_T                            dm_enable_device_ut_mode_req;
    DM_HCI_REFRESH_ENCRYPTION_KEY_IND_T                     dm_encryption_key_refresh_ind;
    DM_HCI_ENHANCED_FLUSH_CFM_T                             dm_enhanced_flush_cfm;
    DM_HCI_ENHANCED_FLUSH_REQ_T                             dm_enhanced_flush_req;
    DM_HCI_EXIT_PERIODIC_INQUIRY_MODE_CFM_T                 dm_exit_periodic_inquiry_cfm;
    DM_HCI_EXIT_PERIODIC_INQUIRY_MODE_REQ_T                 dm_exit_periodic_inquiry_req;
    DM_HCI_EXIT_SNIFF_MODE_REQ_T                            dm_exit_sniff_mode_req;
    DM_HCI_EXTENDED_INQUIRY_RESULT_IND_T                    dm_extended_inquiry_result_ind;
    DM_HCI_READ_FAILED_CONTACT_COUNT_CFM_T                  dm_failed_contact_counter_cfm;
    DM_HCI_READ_FAILED_CONTACT_COUNT_REQ_T                  dm_failed_contact_counter_req;
    DM_HCI_FLOW_SPEC_CFM_T                                  dm_flow_spec_cfm;
    DM_HCI_FLOW_SPEC_REQ_T                                  dm_flow_spec_req;
    DM_HCI_FLUSH_CFM_T                                      dm_flush_cfm;
    DM_HCI_FLUSH_REQ_T                                      dm_flush_req;
    DM_HCI_GET_LINK_QUALITY_CFM_T                           dm_get_link_quality_cfm;
    DM_HCI_GET_LINK_QUALITY_REQ_T                           dm_get_link_quality_req;
    DM_HCI_HOLD_MODE_REQ_T                                  dm_hold_mode_req;
    DM_HCI_HOST_NUM_COMPLETED_PACKETS_REQ_T                 dm_host_num_completed_packets_req;
    DM_HCI_INQUIRY_CANCEL_CFM_T                             dm_inquiry_cancel_cfm;
    DM_HCI_INQUIRY_CANCEL_REQ_T                             dm_inquiry_cancel_req;
    DM_HCI_INQUIRY_CFM_T                                    dm_inquiry_cfm;
    DM_HCI_INQUIRY_RESULT_IND_T                             dm_inquiry_result_ind;
    DM_HCI_INQUIRY_RESULT_WITH_RSSI_IND_T                   dm_inquiry_result_with_rssi_ind;
    DM_HCI_INQUIRY_REQ_T                                    dm_inquiry_req;
    DM_HCI_CHANGE_CONN_LINK_KEY_CFM_T                       dm_link_key_change_cfm;
    DM_HCI_LINK_SUPERV_TIMEOUT_IND_T                        dm_link_superv_timeout_ind;
    DM_HCI_MASTER_LINK_KEY_CFM_T                            dm_master_link_key_cfm;
    DM_HCI_MASTER_LINK_KEY_REQ_T                            dm_master_link_key_req;
    DM_HCI_MODE_CHANGE_EVENT_IND_T                          dm_mode_change_event_ind;
    DM_HCI_PERIODIC_INQUIRY_MODE_CFM_T                      dm_periodic_inquiry_cfm;
    DM_HCI_PERIODIC_INQUIRY_MODE_REQ_T                      dm_periodic_inquiry_req;
    DM_HCI_QOS_SETUP_CFM_T                                  dm_qos_setup_cfm;
    DM_HCI_QOS_SETUP_REQ_T                                  dm_qos_setup_req;
    DM_HCI_READ_AFH_CHANNEL_CLASS_M_CFM_T                   dm_read_afh_channel_class_m_cfm;
    DM_HCI_READ_AFH_CHANNEL_CLASS_M_REQ_T                   dm_read_afh_channel_class_m_req;
    DM_HCI_READ_AFH_CHANNEL_MAP_CFM_T                       dm_read_afh_channel_map_cfm;
    DM_HCI_READ_AFH_CHANNEL_MAP_REQ_T                       dm_read_afh_channel_map_req;
    DM_HCI_READ_AUTH_ENABLE_CFM_T                           dm_read_auth_enable_cfm;
    DM_HCI_READ_AUTH_ENABLE_REQ_T                           dm_read_auth_enable_req;
    DM_HCI_READ_AUTO_FLUSH_TIMEOUT_CFM_T                    dm_read_auto_flush_timeout_cfm;
    DM_HCI_READ_AUTO_FLUSH_TIMEOUT_REQ_T                    dm_read_auto_flush_timeout_req;
    DM_HCI_READ_BD_ADDR_CFM_T                               dm_read_bd_addr_cfm;
    DM_HCI_READ_BD_ADDR_REQ_T                               dm_read_bd_addr_req;
    DM_HCI_READ_CLASS_OF_DEVICE_CFM_T                       dm_read_class_of_device_cfm;
    DM_HCI_READ_CLASS_OF_DEVICE_REQ_T                       dm_read_class_of_device_req;
    DM_HCI_READ_CLOCK_CFM_T                                 dm_read_clock_cfm;
    DM_HCI_READ_CLOCK_OFFSET_CFM_T                          dm_read_clock_offset_cfm;
    DM_HCI_READ_CLOCK_OFFSET_REQ_T                          dm_read_clock_offset_req;
    DM_HCI_READ_CLOCK_REQ_T                                 dm_read_clock_req;
    DM_HCI_READ_CONN_ACCEPT_TIMEOUT_CFM_T                   dm_read_conn_accept_to_cfm;
    DM_HCI_READ_CONN_ACCEPT_TIMEOUT_REQ_T                   dm_read_conn_accept_to_req;
    DM_HCI_READ_COUNTRY_CODE_CFM_T                          dm_read_country_code_cfm;
    DM_HCI_READ_COUNTRY_CODE_REQ_T                          dm_read_country_code_req;
    DM_HCI_READ_CURRENT_IAC_LAP_CFM_T                       dm_read_current_iac_lap_cfm;
    DM_HCI_READ_CURRENT_IAC_LAP_REQ_T                       dm_read_current_iac_lap_req;
    DM_HCI_READ_DEFAULT_LINK_POLICY_SETTINGS_CFM_T          dm_read_default_link_policy_settings_cfm;
    DM_HCI_READ_DEFAULT_LINK_POLICY_SETTINGS_REQ_T          dm_read_default_link_policy_settings_req;
    DM_HCI_READ_ENC_MODE_CFM_T                              dm_read_encryption_mode_cfm;
    DM_HCI_READ_ENC_MODE_REQ_T                              dm_read_encryption_mode_req;
    DM_HCI_READ_ENCRYPTION_KEY_SIZE_CFM_T                   dm_read_encryption_key_size_cfm;
    DM_HCI_READ_ENCRYPTION_KEY_SIZE_REQ_T                   dm_read_encryption_key_size_req;
    DM_HCI_READ_EXTENDED_INQUIRY_RESPONSE_DATA_CFM_T        dm_read_extended_inquiry_response_data_cfm;
    DM_HCI_READ_EXTENDED_INQUIRY_RESPONSE_DATA_REQ_T        dm_read_extended_inquiry_response_data_req;
    DM_HCI_READ_HOLD_MODE_ACTIVITY_CFM_T                    dm_read_hold_mode_activity_cfm;
    DM_HCI_READ_HOLD_MODE_ACTIVITY_REQ_T                    dm_read_hold_mode_activity_req;
    DM_HCI_READ_INQUIRY_MODE_CFM_T                          dm_read_inquiry_mode_cfm;
    DM_HCI_READ_INQUIRY_MODE_REQ_T                          dm_read_inquiry_mode_req;
    DM_HCI_READ_INQUIRY_RESPONSE_TX_POWER_LEVEL_CFM_T       dm_read_inquiry_response_tx_power_level_cfm;
    DM_HCI_READ_INQUIRY_RESPONSE_TX_POWER_LEVEL_REQ_T       dm_read_inquiry_response_tx_power_level_req;
    DM_HCI_READ_INQUIRYSCAN_ACTIVITY_CFM_T                  dm_read_inquiryscan_activity_cfm;
    DM_HCI_READ_INQUIRYSCAN_ACTIVITY_REQ_T                  dm_read_inquiryscan_activity_req;
    DM_HCI_READ_INQUIRY_SCAN_TYPE_CFM_T                     dm_read_inquiry_scan_type_cfm;
    DM_HCI_READ_INQUIRY_SCAN_TYPE_REQ_T                     dm_read_inquiry_scan_type_req;
    DM_HCI_READ_LINK_SUPERV_TIMEOUT_CFM_T                   dm_read_link_superv_timeout_cfm;
    DM_HCI_READ_LINK_SUPERV_TIMEOUT_REQ_T                   dm_read_link_superv_timeout_req;
    DM_HCI_READ_LMP_HANDLE_CFM_T                            dm_read_lmp_handle_cfm;
    DM_HCI_READ_LMP_HANDLE_REQ_T                            dm_read_lmp_handle_req;
    DM_HCI_READ_LOCAL_EXT_FEATURES_CFM_T                    dm_read_local_ext_features_cfm;
    DM_HCI_READ_LOCAL_EXT_FEATURES_REQ_T                    dm_read_local_ext_features_req;
    DM_HCI_READ_LOCAL_SUPP_FEATURES_CFM_T                   dm_read_local_features_cfm;
    DM_HCI_READ_LOCAL_SUPP_FEATURES_REQ_T                   dm_read_local_features_req;
    DM_HCI_READ_LOCAL_NAME_CFM_T                            dm_read_local_name_cfm;
    DM_HCI_READ_LOCAL_NAME_REQ_T                            dm_read_local_name_req;
    DM_HCI_READ_LOCAL_VER_INFO_CFM_T                        dm_read_local_version_cfm;
    DM_HCI_READ_LOCAL_VER_INFO_REQ_T                        dm_read_local_version_req;
    DM_HCI_READ_LINK_POLICY_SETTINGS_CFM_T                  dm_read_lp_settings_cfm;
    DM_HCI_READ_LINK_POLICY_SETTINGS_REQ_T                  dm_read_lp_settings_req;
    DM_HCI_READ_NUM_BCAST_RETXS_CFM_T                       dm_read_num_bcast_txs_cfm;
    DM_HCI_READ_NUM_BCAST_RETXS_REQ_T                       dm_read_num_bcast_txs_req;
    DM_HCI_READ_NUM_SUPPORTED_IAC_CFM_T                     dm_read_num_supported_iac_cfm;
    DM_HCI_READ_NUM_SUPPORTED_IAC_REQ_T                     dm_read_num_supported_iac_req;
    DM_HCI_READ_PAGESCAN_ACTIVITY_CFM_T                     dm_read_pagescan_activity_cfm;
    DM_HCI_READ_PAGESCAN_ACTIVITY_REQ_T                     dm_read_pagescan_activity_req;
    DM_HCI_READ_PAGESCAN_MODE_CFM_T                         dm_read_pagescan_mode_cfm;
    DM_HCI_READ_PAGESCAN_MODE_REQ_T                         dm_read_pagescan_mode_req;
    DM_HCI_READ_PAGESCAN_PERIOD_MODE_CFM_T                  dm_read_pagescan_period_mode_cfm;
    DM_HCI_READ_PAGESCAN_PERIOD_MODE_REQ_T                  dm_read_pagescan_period_mode_req;
    DM_HCI_READ_PAGE_SCAN_TYPE_CFM_T                        dm_read_page_scan_type_cfm;
    DM_HCI_READ_PAGE_SCAN_TYPE_REQ_T                        dm_read_page_scan_type_req;
    DM_HCI_READ_PAGE_TIMEOUT_CFM_T                          dm_read_page_to_cfm;
    DM_HCI_READ_PAGE_TIMEOUT_REQ_T                          dm_read_page_to_req;
    DM_HCI_READ_PIN_TYPE_CFM_T                              dm_read_pin_type_cfm;
    DM_HCI_READ_PIN_TYPE_REQ_T                              dm_read_pin_type_req;
    DM_HCI_READ_REMOTE_EXT_FEATURES_CFM_T                   dm_read_remote_ext_features_cfm;
    DM_HCI_READ_REMOTE_EXT_FEATURES_REQ_T                   dm_read_remote_ext_features_req;
    DM_HCI_READ_REMOTE_SUPP_FEATURES_CFM_T                  dm_read_remote_features_cfm;
    DM_HCI_READ_REMOTE_SUPP_FEATURES_REQ_T                  dm_read_remote_features_req;
    DM_HCI_READ_REMOTE_VER_INFO_CFM_T                       dm_read_remote_version_cfm;
    DM_HCI_READ_REMOTE_VER_INFO_REQ_T                       dm_read_remote_version_req;
    DM_HCI_READ_RSSI_CFM_T                                  dm_read_rssi_cfm;
    DM_HCI_READ_RSSI_REQ_T                                  dm_read_rssi_req;
    DM_HCI_READ_SCAN_ENABLE_CFM_T                           dm_read_scan_enable_cfm;
    DM_HCI_READ_SCAN_ENABLE_REQ_T                           dm_read_scan_enable_req;
    DM_HCI_READ_SCO_FLOW_CON_ENABLE_CFM_T                   dm_read_sco_flow_control_enable_cfm;
    DM_HCI_READ_SCO_FLOW_CON_ENABLE_REQ_T                   dm_read_sco_flow_control_enable_req;
    DM_HCI_READ_STORED_LINK_KEY_CFM_T                       dm_read_stored_link_key_cfm;
    DM_HCI_READ_STORED_LINK_KEY_REQ_T                       dm_read_stored_link_key_req;
    DM_HCI_READ_TX_POWER_LEVEL_CFM_T                        dm_read_tx_power_level_cfm;
    DM_HCI_READ_TX_POWER_LEVEL_REQ_T                        dm_read_tx_power_level_req;
    DM_HCI_READ_VOICE_SETTING_CFM_T                         dm_read_voice_setting_cfm;
    DM_HCI_READ_VOICE_SETTING_REQ_T                         dm_read_voice_setting_req;
    DM_HCI_REFRESH_ENCRYPTION_KEY_REQ_T                     dm_refresh_encryption_key_req;
    DM_HCI_REM_HOST_SUPPORTED_FEATURES_IND_T                dm_rem_host_supported_features_ind;
    DM_HCI_REMOTE_NAME_CFM_T                                dm_remote_name_cfm;
    DM_HCI_REMOTE_NAME_REQ_CANCEL_CFM_T                     dm_remote_name_req_cancel_cfm;
    DM_HCI_REMOTE_NAME_REQ_CANCEL_REQ_T                     dm_remote_name_req_cancel_req;
    DM_HCI_REMOTE_NAME_REQUEST_REQ_T                        dm_remote_name_request_req;
    DM_HCI_RESET_CFM_T                                      dm_reset_cfm;
    DM_HCI_RESET_FAILED_CONTACT_COUNT_CFM_T                 dm_reset_contact_counter_cfm;
    DM_HCI_RESET_FAILED_CONTACT_COUNT_REQ_T                 dm_reset_contact_counter_req;
    DM_HCI_RESET_REQ_T                                      dm_reset_req;
    DM_HCI_RETURN_LINK_KEYS_IND_T                           dm_return_link_keys_ind;
    DM_HCI_ROLE_DISCOVERY_CFM_T                             dm_role_discovery_cfm;
    DM_HCI_ROLE_DISCOVERY_REQ_T                             dm_role_discovery_req;
    DM_HCI_SET_AFH_CHANNEL_CLASS_CFM_T                      dm_set_afh_channel_class_cfm;
    DM_HCI_SET_AFH_CHANNEL_CLASS_REQ_T                      dm_set_afh_channel_class_req;
    DM_HCI_SET_EVENT_FILTER_CFM_T                           dm_set_event_filter_cfm;
    DM_HCI_SET_EVENT_FILTER_REQ_T                           dm_set_event_filter_req;
    DM_HCI_SET_EVENT_MASK_CFM_T                             dm_set_event_mask_cfm;
    DM_HCI_SET_EVENT_MASK_REQ_T                             dm_set_event_mask_req;
    DM_HCI_SNIFF_MODE_REQ_T                                 dm_sniff_mode_req;
    DM_HCI_SNIFF_SUB_RATE_CFM_T                             dm_sniff_sub_rate_cfm;
    DM_HCI_SNIFF_SUB_RATE_REQ_T                             dm_sniff_sub_rate_req;
    DM_HCI_SNIFF_SUB_RATING_IND_T                           dm_sniff_sub_rating_ind;
    DM_HCI_SWITCH_ROLE_CFM_T                                dm_switch_role_cfm;
    DM_HCI_SWITCH_ROLE_REQ_T                                dm_switch_role_req;
    DM_HCI_READ_SECURE_CONNECTIONS_HOST_SUPPORT_CFM_T       dm_read_secure_connections_host_support_cfm;
    DM_HCI_READ_SECURE_CONNECTIONS_HOST_SUPPORT_REQ_T       dm_read_secure_connections_host_support_req;
    DM_HCI_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT_CFM_T      dm_write_secure_connections_host_support_cfm;
    DM_HCI_WRITE_SECURE_CONNECTIONS_HOST_SUPPORT_REQ_T      dm_write_secure_connections_host_support_req;
    DM_HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_CFM_T         dm_read_authenticated_payload_timeout_cfm;
    DM_HCI_READ_AUTHENTICATED_PAYLOAD_TIMEOUT_REQ_T         dm_read_authenticated_payload_timeout_req;
    DM_HCI_AUTHENTICATED_PAYLOAD_TIMEOUT_EXPIRED_IND_T      dm_hci_apt_expired_ind;

#ifdef INSTALL_ULP
    DM_SET_BLE_CONNECTION_PARAMETERS_REQ_T                  dm_set_ble_connection_parameters_req;
    DM_SET_BLE_CONNECTION_PARAMETERS_CFM_T                  dm_set_ble_connection_parameters_cfm;
    DM_BLE_ACCEPT_CONNECTION_PAR_UPDATE_IND_T               dm_ble_accept_connection_par_update_ind;
    DM_BLE_ACCEPT_CONNECTION_PAR_UPDATE_RSP_T               dm_ble_accept_connection_par_update_rsp;
    DM_BLE_UPDATE_CONNECTION_PARAMETERS_REQ_T               dm_ble_update_connection_parameters_req;
    DM_BLE_UPDATE_CONNECTION_PARAMETERS_CFM_T               dm_ble_update_connection_parameters_cfm;
    DM_HCI_ULP_ADVERTISING_REPORT_IND_T                     dm_ulp_advertising_report_ind;
    DM_HCI_ULP_SET_EVENT_MASK_REQ_T                         dm_ulp_set_event_mask_req;
    DM_HCI_ULP_SET_EVENT_MASK_CFM_T                         dm_ulp_set_event_mask_cfm;
    DM_HCI_ULP_READ_LOCAL_SUPPORTED_FEATURES_REQ_T          dm_ulp_read_local_supported_features_req;
    DM_HCI_ULP_READ_LOCAL_SUPPORTED_FEATURES_CFM_T          dm_ulp_read_local_supported_features_cfm;
    DM_HCI_ULP_SET_ADVERTISING_PARAMETERS_REQ_T             dm_ulp_set_advertising_parameters_req;
    DM_HCI_ULP_SET_ADVERTISING_PARAMETERS_CFM_T             dm_ulp_set_advertising_parameters_cfm;
    DM_HCI_ULP_READ_ADVERTISING_CHANNEL_TX_POWER_REQ_T      dm_ulp_read_advertising_channel_tx_power_req;
    DM_HCI_ULP_READ_ADVERTISING_CHANNEL_TX_POWER_CFM_T      dm_ulp_read_advertising_channel_tx_power_cfm;
    DM_HCI_ULP_SET_ADVERTISING_DATA_REQ_T                   dm_ulp_set_advertising_data_req;
    DM_HCI_ULP_SET_ADVERTISING_DATA_CFM_T                   dm_ulp_set_advertising_data_cfm;
    DM_HCI_ULP_SET_SCAN_RESPONSE_DATA_REQ_T                 dm_ulp_set_scan_response_data_req;
    DM_HCI_ULP_SET_SCAN_RESPONSE_DATA_CFM_T                 dm_ulp_set_scan_response_data_cfm;
    DM_HCI_ULP_SET_ADVERTISE_ENABLE_REQ_T                   dm_ulp_set_advertise_enable_req;
    DM_HCI_ULP_SET_ADVERTISE_ENABLE_CFM_T                   dm_ulp_set_advertise_enable_cfm;
    DM_HCI_ULP_SET_SCAN_PARAMETERS_REQ_T                    dm_ulp_set_scan_parameters_req;
    DM_HCI_ULP_SET_SCAN_PARAMETERS_CFM_T                    dm_ulp_set_scan_parameters_cfm;
    DM_HCI_ULP_SET_SCAN_ENABLE_REQ_T                        dm_ulp_set_scan_enable_req;
    DM_HCI_ULP_SET_SCAN_ENABLE_CFM_T                        dm_ulp_set_scan_enable_cfm;
    DM_HCI_ULP_CREATE_CONNECTION_CANCEL_REQ_T               dm_ulp_create_connection_cancel_req;
    DM_HCI_ULP_CREATE_CONNECTION_CANCEL_CFM_T               dm_ulp_create_connection_cancel_cfm;
    DM_HCI_ULP_READ_WHITE_LIST_SIZE_REQ_T                   dm_ulp_read_white_list_size_req;
    DM_HCI_ULP_READ_WHITE_LIST_SIZE_CFM_T                   dm_ulp_read_white_list_size_cfm;
    DM_HCI_ULP_CLEAR_WHITE_LIST_REQ_T                       dm_ulp_clear_white_list_req;
    DM_HCI_ULP_CLEAR_WHITE_LIST_CFM_T                       dm_ulp_clear_white_list_cfm;
    DM_HCI_ULP_ADD_DEVICE_TO_WHITE_LIST_REQ_T               dm_ulp_add_device_to_white_list_req;
    DM_HCI_ULP_ADD_DEVICE_TO_WHITE_LIST_CFM_T               dm_ulp_add_device_to_white_list_cfm;
    DM_HCI_ULP_REMOVE_DEVICE_FROM_WHITE_LIST_REQ_T          dm_ulp_remove_device_from_white_list_req;
    DM_HCI_ULP_REMOVE_DEVICE_FROM_WHITE_LIST_CFM_T          dm_ulp_remove_device_from_white_list_cfm;
    DM_HCI_ULP_SET_HOST_CHANNEL_CLASSIFICATION_REQ_T        dm_ulp_set_host_channel_classification_req;
    DM_HCI_ULP_SET_HOST_CHANNEL_CLASSIFICATION_CFM_T        dm_ulp_set_host_channel_classification_cfm;
    DM_HCI_ULP_READ_CHANNEL_MAP_REQ_T                       dm_ulp_read_channel_map_req;
    DM_HCI_ULP_READ_CHANNEL_MAP_CFM_T                       dm_ulp_read_channel_map_cfm;
    DM_HCI_ULP_READ_REMOTE_USED_FEATURES_REQ_T              dm_ulp_read_remote_used_features_req;
    DM_HCI_ULP_READ_REMOTE_USED_FEATURES_CFM_T              dm_ulp_read_remote_used_features_cfm;
    DM_HCI_ULP_ENCRYPT_REQ_T                                dm_ulp_encrypt_req;
    DM_HCI_ULP_ENCRYPT_CFM_T                                dm_ulp_encrypt_cfm;
    DM_HCI_ULP_RAND_REQ_T                                   dm_ulp_rand_req;
    DM_HCI_ULP_RAND_CFM_T                                   dm_ulp_rand_cfm;
    DM_HCI_ULP_READ_SUPPORTED_STATES_REQ_T                  dm_ulp_read_supported_states_req;
    DM_HCI_ULP_READ_SUPPORTED_STATES_CFM_T                  dm_ulp_read_supported_states_cfm;
    DM_HCI_ULP_RECEIVER_TEST_REQ_T                          dm_ulp_receiver_test_req;
    DM_HCI_ULP_RECEIVER_TEST_CFM_T                          dm_ulp_receiver_test_cfm;
    DM_HCI_ULP_TRANSMITTER_TEST_REQ_T                       dm_ulp_transmitter_test_req;
    DM_HCI_ULP_TRANSMITTER_TEST_CFM_T                       dm_ulp_transmitter_test_cfm;
    DM_HCI_ULP_TEST_END_REQ_T                               dm_ulp_test_end_req;
    DM_HCI_ULP_TEST_END_CFM_T                               dm_ulp_test_end_cfm;
    DM_ULP_ENABLE_ZERO_SLAVE_LATENCY_REQ_T                  dm_ulp_enable_zero_slave_latency_req;
    DM_ULP_ENABLE_ZERO_SLAVE_LATENCY_CFM_T                  dm_ulp_enable_zero_slave_latency_cfm;
    DM_HCI_ULP_CHANNEL_SELECTION_ALGORITHM_IND_T            dm_ulp_channel_selection_algorithm_ind;
    DM_HCI_ULP_READ_RESOLVING_LIST_SIZE_REQ_T               dm_ulp_read_resolving_list_size_req;
    DM_HCI_ULP_READ_RESOLVING_LIST_SIZE_CFM_T               dm_ulp_read_resolving_list_size_cfm;
    DM_HCI_ULP_ENHANCED_RECEIVER_TEST_REQ_T                 dm_ulp_enhanced_receiver_test_req;
    DM_HCI_ULP_ENHANCED_RECEIVER_TEST_CFM_T                 dm_ulp_enhanced_receiver_test_cfm;
    DM_HCI_ULP_ENHANCED_TRANSMITTER_TEST_REQ_T              dm_ulp_enhanced_transmitter_test_req;
    DM_HCI_ULP_ENHANCED_TRANSMITTER_TEST_CFM_T              dm_ulp_enhanced_transmitter_test_cfm;
#endif

    DM_HCI_WRITE_AFH_CHANNEL_CLASS_M_CFM_T                  dm_write_afh_channel_class_m_cfm;
    DM_HCI_WRITE_AFH_CHANNEL_CLASS_M_REQ_T                  dm_write_afh_channel_class_m_req;
    DM_HCI_WRITE_AUTO_FLUSH_TIMEOUT_CFM_T                   dm_write_auto_flush_timeout_cfm;
    DM_HCI_WRITE_AUTO_FLUSH_TIMEOUT_REQ_T                   dm_write_auto_flush_timeout_req;
    DM_HCI_WRITE_CLASS_OF_DEVICE_CFM_T                      dm_write_class_of_device_cfm;
    DM_HCI_WRITE_CLASS_OF_DEVICE_REQ_T                      dm_write_class_of_device_req;
    DM_HCI_WRITE_CONN_ACCEPT_TIMEOUT_CFM_T                  dm_write_conn_accept_to_cfm;
    DM_HCI_WRITE_CONN_ACCEPT_TIMEOUT_REQ_T                  dm_write_conn_accept_to_req;
    DM_HCI_WRITE_CURRENT_IAC_LAP_CFM_T                      dm_write_current_iac_lap_cfm;
    DM_HCI_WRITE_CURRENT_IAC_LAP_REQ_T                      dm_write_current_iac_lap_req;
    DM_HCI_WRITE_DEFAULT_LINK_POLICY_SETTINGS_CFM_T         dm_write_default_link_policy_settings_cfm;
    DM_HCI_WRITE_DEFAULT_LINK_POLICY_SETTINGS_REQ_T         dm_write_default_link_policy_settings_req;
    DM_HCI_WRITE_EXTENDED_INQUIRY_RESPONSE_DATA_CFM_T       dm_write_extended_inquiry_response_data_cfm;
    DM_HCI_WRITE_EXTENDED_INQUIRY_RESPONSE_DATA_REQ_T       dm_write_extended_inquiry_response_data_req;
    DM_HCI_WRITE_HOLD_MODE_ACTIVITY_CFM_T                   dm_write_hold_mode_activity_cfm;
    DM_HCI_WRITE_HOLD_MODE_ACTIVITY_REQ_T                   dm_write_hold_mode_activity_req;
    DM_HCI_WRITE_INQUIRY_MODE_CFM_T                         dm_write_inquiry_mode_cfm;
    DM_HCI_WRITE_INQUIRY_MODE_REQ_T                         dm_write_inquiry_mode_req;
    DM_HCI_WRITE_INQUIRYSCAN_ACTIVITY_CFM_T                 dm_write_inquiryscan_activity_cfm;
    DM_HCI_WRITE_INQUIRYSCAN_ACTIVITY_REQ_T                 dm_write_inquiryscan_activity_req;
    DM_HCI_WRITE_INQUIRY_SCAN_TYPE_CFM_T                    dm_write_inquiry_scan_type_cfm;
    DM_HCI_WRITE_INQUIRY_SCAN_TYPE_REQ_T                    dm_write_inquiry_scan_type_req;
    DM_HCI_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_CFM_T         dm_write_inquiry_transmit_power_level_cfm;
    DM_HCI_WRITE_INQUIRY_TRANSMIT_POWER_LEVEL_REQ_T         dm_write_inquiry_transmit_power_level_req;
    DM_HCI_WRITE_LINK_SUPERV_TIMEOUT_CFM_T                  dm_write_link_superv_timeout_cfm;
    DM_HCI_WRITE_LINK_SUPERV_TIMEOUT_REQ_T                  dm_write_link_superv_timeout_req;
    DM_HCI_WRITE_LINK_POLICY_SETTINGS_CFM_T                 dm_write_link_policy_settings_cfm;
    DM_HCI_WRITE_LINK_POLICY_SETTINGS_REQ_T                 dm_write_link_policy_settings_req;
    DM_HCI_WRITE_NUM_BCAST_RETXS_CFM_T                      dm_write_num_bcast_txs_cfm;
    DM_HCI_WRITE_NUM_BCAST_RETXS_REQ_T                      dm_write_num_bcast_txs_req;
    DM_HCI_WRITE_PAGESCAN_ACTIVITY_CFM_T                    dm_write_pagescan_activity_cfm;
    DM_HCI_WRITE_PAGESCAN_ACTIVITY_REQ_T                    dm_write_pagescan_activity_req;
    DM_HCI_WRITE_PAGESCAN_MODE_CFM_T                        dm_write_pagescan_mode_cfm;
    DM_HCI_WRITE_PAGESCAN_MODE_REQ_T                        dm_write_pagescan_mode_req;
    DM_HCI_WRITE_PAGESCAN_PERIOD_MODE_CFM_T                 dm_write_pagescan_period_mode_cfm;
    DM_HCI_WRITE_PAGESCAN_PERIOD_MODE_REQ_T                 dm_write_pagescan_period_mode_req;
    DM_HCI_WRITE_PAGE_SCAN_TYPE_CFM_T                       dm_write_page_scan_type_cfm;
    DM_HCI_WRITE_PAGE_SCAN_TYPE_REQ_T                       dm_write_page_scan_type_req;
    DM_HCI_WRITE_PAGE_TIMEOUT_CFM_T                         dm_write_page_to_cfm;
    DM_HCI_WRITE_PAGE_TIMEOUT_REQ_T                         dm_write_page_to_req;
    DM_HCI_WRITE_PIN_TYPE_CFM_T                             dm_write_pin_type_cfm;
    DM_HCI_WRITE_PIN_TYPE_REQ_T                             dm_write_pin_type_req;
    DM_HCI_WRITE_SCAN_ENABLE_CFM_T                          dm_write_scan_enable_cfm;
    DM_HCI_WRITE_SCAN_ENABLE_REQ_T                          dm_write_scan_enable_req;
    DM_HCI_WRITE_SCO_FLOW_CON_ENABLE_CFM_T                  dm_write_sco_flow_control_enable_cfm;
    DM_HCI_WRITE_SCO_FLOW_CON_ENABLE_REQ_T                  dm_write_sco_flow_control_enable_req;
    DM_HCI_WRITE_STORED_LINK_KEY_CFM_T                      dm_write_stored_link_key_cfm;
    DM_HCI_WRITE_STORED_LINK_KEY_REQ_T                      dm_write_stored_link_key_req;
    DM_HCI_WRITE_VOICE_SETTING_CFM_T                        dm_write_voice_setting_cfm;
    DM_HCI_WRITE_VOICE_SETTING_REQ_T                        dm_write_voice_setting_req;

    DM_LP_WRITE_POWERSTATES_CFM_T                           dm_lp_write_powerstates_cfm;
    DM_LP_WRITE_POWERSTATES_REQ_T                           dm_lp_write_powerstates_req;
    DM_LP_WRITE_ROLESWITCH_POLICY_REQ_T                     dm_lp_write_roleswitch_policy_req;
    DM_LP_WRITE_ROLESWITCH_POLICY_CFM_T                     dm_lp_write_roleswitch_policy_cfm;
    DM_LP_WRITE_ALWAYS_MASTER_DEVICES_REQ_T                 dm_lp_write_always_master_devices_req;
    DM_LP_WRITE_ALWAYS_MASTER_DEVICES_CFM_T                 dm_lp_write_always_master_devices_cfm;

    DM_SET_BT_VERSION_CFM_T                                 dm_set_bt_version_cfm;
    DM_SET_BT_VERSION_REQ_T                                 dm_set_bt_version_req;

    DM_SET_DEFAULT_LINK_POLICY_REQ_T                        dm_set_default_link_policy_req;
    DM_SET_LINK_BEHAVIOR_REQ_T                              dm_set_link_behavior_req;
    DM_SET_LINK_BEHAVIOR_CFM_T                              dm_set_link_behavior_cfm;

    DM_SM_ACCESS_CFM_T                                      dm_sm_access_cfm;
    DM_SM_ACCESS_IND_T                                      dm_sm_access_ind;
    DM_SM_ACCESS_REQ_T                                      dm_sm_access_req;
    DM_SM_ADD_DEVICE_CFM_T                                  dm_sm_add_device_cfm;
    DM_SM_ADD_DEVICE_REQ_T                                  dm_sm_add_device_req;
    DM_SM_AUTHENTICATE_CFM_T                                dm_sm_authenticate_cfm;
    DM_SM_AUTHENTICATE_REQ_T                                dm_sm_authenticate_req;
    DM_SM_AUTHORISE_IND_T                                   dm_sm_authorise_ind;
    DM_SM_AUTHORISE_RSP_T                                   dm_sm_authorise_rsp;
    DM_SM_BONDING_CANCEL_REQ_T                              dm_sm_bonding_cancel_req;
    DM_SM_BONDING_CFM_T                                     dm_sm_bonding_cfm;
    DM_SM_BONDING_REQ_T                                     dm_sm_bonding_req;
    DM_SM_ENCRYPT_CFM_T                                     dm_sm_encrypt_cfm;
    DM_SM_ENCRYPTION_CHANGE_IND_T                           dm_sm_encryption_change_ind;
    DM_SM_ENCRYPTION_CHANGE_KEY_SIZE_IND_T                  dm_sm_encryption_change_key_size_ind;
    DM_SM_ENCRYPT_REQ_T                                     dm_sm_encrypt_req;
    DM_SM_IO_CAPABILITY_REQUEST_IND_T                       dm_sm_io_capability_request_ind;
    DM_SM_IO_CAPABILITY_REQUEST_NEG_RSP_T                   dm_sm_io_capability_request_neg_rsp;
    DM_SM_IO_CAPABILITY_REQUEST_RSP_T                       dm_sm_io_capability_request_rsp;
    DM_SM_IO_CAPABILITY_RESPONSE_IND_T                      dm_sm_io_capability_response_ind;
    DM_SM_KEYPRESS_NOTIFICATION_IND_T                       dm_sm_keypress_notification_ind;
    DM_SM_LINK_KEY_IND_T                                    dm_sm_link_key_ind;
    DM_SM_LINK_KEY_REQUEST_IND_T                            dm_sm_link_key_request_ind;
    DM_SM_LINK_KEY_REQUEST_RSP_T                            dm_sm_link_key_request_rsp;
    DM_SM_PIN_REQUEST_IND_T                                 dm_sm_pin_request_ind;
    DM_SM_PIN_REQUEST_RSP_T                                 dm_sm_pin_request_rsp;
    DM_SM_READ_DEVICE_CFM_T                                 dm_sm_read_device_cfm;
    DM_SM_READ_DEVICE_REQ_T                                 dm_sm_read_device_req;
    DM_SM_READ_LOCAL_OOB_DATA_CFM_T                         dm_sm_read_local_oob_data_cfm;
    DM_SM_READ_LOCAL_OOB_DATA_REQ_T                         dm_sm_read_local_oob_data_req;
    DM_SM_REGISTER_OUTGOING_CFM_T                           dm_sm_register_outgoing_cfm;
    DM_SM_REGISTER_OUTGOING_REQ_T                           dm_sm_register_outgoing_req;
    DM_SM_REGISTER_CFM_T                                    dm_sm_register_cfm;
    DM_SM_REGISTER_REQ_T                                    dm_sm_register_req;
    DM_SM_REMOVE_DEVICE_CFM_T                               dm_sm_remove_device_cfm;
    DM_SM_REMOVE_DEVICE_REQ_T                               dm_sm_remove_device_req;
    DM_SM_SEND_KEYPRESS_NOTIFICATION_REQ_T                  dm_sm_send_keypress_notification_req;
    DM_SM_INIT_REQ_T                                        dm_sm_init_req;
    DM_SM_INIT_CFM_T                                        dm_sm_init_cfm;
    DM_SM_KEY_REQUEST_IND_T                                 dm_sm_key_request_ind;
    DM_SM_KEY_REQUEST_RSP_T                                 dm_sm_key_request_rsp;
    DM_SM_KEY_REQUEST_NEG_RSP_T                             dm_sm_key_request_neg_rsp;
    DM_SM_KEYS_IND_T                                        dm_sm_keys_ind;
    DM_SM_SECURITY_CFM_T                                    dm_sm_security_cfm;
    DM_SM_SECURITY_COMMON_T                                 dm_sm_security_common;
    DM_SM_SECURITY_IND_T                                    dm_sm_security_ind;
    DM_SM_SIMPLE_PAIRING_COMPLETE_IND_T                     dm_sm_simple_pairing_complete_ind;
    DM_SM_UNREGISTER_OUTGOING_CFM_T                         dm_sm_unregister_outgoing_cfm;
    DM_SM_UNREGISTER_OUTGOING_REQ_T                         dm_sm_unregister_outgoing_req;
    DM_SM_UNREGISTER_CFM_T                                  dm_sm_unregister_cfm;
    DM_SM_UNREGISTER_REQ_T                                  dm_sm_unregister_req;
    DM_SM_USER_CONFIRMATION_REQUEST_IND_T                   dm_sm_user_confirmation_request_ind;
    DM_SM_USER_CONFIRMATION_REQUEST_NEG_RSP_T               dm_sm_user_confirmation_request_neg_rsp;
    DM_SM_USER_CONFIRMATION_REQUEST_RSP_T                   dm_sm_user_confirmation_request_rsp;
    DM_SM_USER_PASSKEY_NOTIFICATION_IND_T                   dm_sm_user_passkey_notification_ind;
    DM_SM_USER_PASSKEY_REQUEST_IND_T                        dm_sm_user_passkey_request_ind;
    DM_SM_USER_PASSKEY_REQUEST_NEG_RSP_T                    dm_sm_user_passkey_request_neg_rsp;
    DM_SM_USER_PASSKEY_REQUEST_RSP_T                        dm_sm_user_passkey_request_rsp;
    DM_SM_READ_LOCAL_OOB_DATA_REQ_T                         dm_sm_handle_read_local_oob_data_req;
    DM_SM_GENERATE_LOCAL_KEY_REQ_T                          dm_sm_generate_local_key_req;
#ifdef INSTALL_SM_MODULE
    DM_SM_SECURITY_REQ_T                                    dm_sm_security_req;
    DM_SM_CSRK_COUNTER_CHANGE_IND_T                         dm_sm_csrk_counter_change_ind;
    DM_SM_DATA_SIGN_COMMON_T                                dm_sm_data_sign_common;
    DM_SM_DATA_SIGN_CFM_T                                   dm_sm_data_sign_cfm;
    DM_SM_DATA_SIGN_REQ_T                                   dm_sm_data_sign_req;
    DM_SM_AUTO_CONFIGURE_LOCAL_ADDRESS_REQ_T                dm_sm_auto_configure_local_address_req;
    DM_SM_AUTO_CONFIGURE_LOCAL_ADDRESS_CFM_T                dm_sm_auto_configure_local_address_cfm;
    DM_SM_READ_RANDOM_ADDRESS_REQ_T                         dm_sm_read_random_address_req;
    DM_SM_READ_RANDOM_ADDRESS_CFM_T                         dm_sm_read_random_address_cfm;
#endif /* INSTALL_SM_MODULE */
    DM_SM_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_CFM_T         dm_sm_write_authenticated_payload_timeout_cfm;
    DM_SM_WRITE_AUTHENTICATED_PAYLOAD_TIMEOUT_REQ_T         dm_sm_write_authenticated_payload_timeout_req;
    DM_SM_SERVICE_REGISTER_REQ_T                            dm_sm_service_register_req;
    DM_SM_SERVICE_REGISTER_OUTGOING_REQ_T                   dm_sm_service_register_outgoing_req;
    DM_SM_READ_LOCAL_IRK_REQ_T                              dm_sm_read_local_irk_req;
    DM_SM_READ_LOCAL_IRK_CFM_T                              dm_sm_read_local_irk_cfm;
    DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_IND_T            dm_sm_generate_cross_trans_key_request_ind;
    DM_SM_GENERATE_CROSS_TRANS_KEY_REQUEST_RSP_T            dm_sm_generate_cross_trans_key_request_rsp;
    DM_SM_CONFIG_REQ_T                                      dm_sm_config_req;
    DM_SM_CONFIG_CFM_T                                      dm_sm_config_cfm;

    DM_SYNC_CONNECT_CFM_T                                   dm_sync_connect_cfm;
    DM_SYNC_CONNECT_COMPLETE_IND_T                          dm_sync_connect_complete_ind;
    DM_SYNC_CONNECT_IND_T                                   dm_sync_connect_ind;
    DM_SYNC_CONNECT_REQ_T                                   dm_sync_connect_req;
    DM_SYNC_CONNECT_RSP_T                                   dm_sync_connect_rsp;
    DM_SYNC_DISCONNECT_CFM_T                                dm_sync_disconnect_cfm;
    DM_SYNC_DISCONNECT_IND_T                                dm_sync_disconnect_ind;
    DM_SYNC_DISCONNECT_REQ_T                                dm_sync_disconnect_req;
    DM_SYNC_REGISTER_CFM_T                                  dm_sync_register_cfm;
    DM_SYNC_REGISTER_REQ_T                                  dm_sync_register_req;
    DM_SYNC_RENEGOTIATE_CFM_T                               dm_sync_renegotiate_cfm;
    DM_SYNC_RENEGOTIATE_IND_T                               dm_sync_renegotiate_ind;
    DM_SYNC_RENEGOTIATE_REQ_T                               dm_sync_renegotiate_req;
    DM_SYNC_UNREGISTER_CFM_T                                dm_sync_unregister_cfm;
    DM_SYNC_UNREGISTER_REQ_T                                dm_sync_unregister_req;

    DM_WRITE_CACHED_CLOCK_OFFSET_CFM_T                      dm_write_cached_clock_offset_cfm;
    DM_WRITE_CACHED_CLOCK_OFFSET_REQ_T                      dm_write_cached_clock_offset_req;
    DM_WRITE_CACHED_PAGE_MODE_CFM_T                         dm_write_cached_page_mode_cfm;
    DM_WRITE_CACHED_PAGE_MODE_REQ_T                         dm_write_cached_page_mode_req;

    DM_HANDLE_DEVICE_BLACK_LIST_REQ_T                       dm_handle_device_black_list_req;
    DM_HANDLE_DEVICE_BLACK_LIST_CFM_T                       dm_handle_device_black_list_cfm;
    DM_HCI_CHANGE_ACL_CONN_PKT_TYPE_REQ_T                   dm_handle_change_acl_conn_pkt_type_req;
    DM_ACL_CONN_HANDLE_IND_T                                dm_acl_conn_handle_ind;
    DM_ACL_CONN_START_IND_T                                 dm_acl_conn_start_ind;
    DM_ULP_ADV_PARAM_UPDATE_IND_T                           dm_ulp_adv_param_update_ind;
    DM_HCI_SET_RESERVED_LT_ADDR_CFM_T                       dm_set_reserved_lt_addr_cfm;
    DM_HCI_SET_RESERVED_LT_ADDR_REQ_T                       dm_set_reserved_lt_addr_req;
    DM_HCI_DELETE_RESERVED_LT_ADDR_CFM_T                    dm_delete_reserved_lt_addr_cfm;
    DM_HCI_DELETE_RESERVED_LT_ADDR_REQ_T                    dm_delete_reserved_lt_addr_req;
    DM_HCI_SET_CSB_CFM_T                                    dm_set_csb_cfm;
    DM_HCI_SET_CSB_REQ_T                                    dm_set_csb_req;
    DM_HCI_SET_CSB_DATA_CFM_T                               dm_set_csb_data_cfm;
    DM_HCI_SET_CSB_DATA_REQ_T                               dm_set_csb_data_req;
    DM_HCI_WRITE_SYNCHRONIZATION_TRAIN_PARAMS_CFM_T         dm_write_synchronization_train_params_cfm;
    DM_HCI_WRITE_SYNCHRONIZATION_TRAIN_PARAMS_REQ_T         dm_write_synchronization_train_params_req;
    DM_HCI_READ_SYNCHRONIZATION_TRAIN_PARAMS_CFM_T          dm_read_synchronization_train_params_cfm;
    DM_HCI_READ_SYNCHRONIZATION_TRAIN_PARAMS_REQ_T          dm_read_synchronization_train_params_req;
    DM_HCI_CONFIGURE_DATA_PATH_REQ_T                        dm_configure_data_path_req;
    DM_HCI_CONFIGURE_DATA_PATH_CFM_T                        dm_configure_data_path_cfm;
    DM_HCI_START_SYNCHRONIZATION_TRAIN_CFM_T                dm_start_synchronization_train_cfm;
    DM_HCI_START_SYNCHRONIZATION_TRAIN_REQ_T                dm_start_synchronization_train_req;
    DM_HCI_TRUNCATED_PAGE_CFM_T                             dm_truncated_page_cfm;
    DM_HCI_TRUNCATED_PAGE_REQ_T                             dm_truncated_page_req;
    DM_HCI_TRUNCATED_PAGE_CANCEL_CFM_T                      dm_truncated_page_cancel_cfm;
    DM_HCI_TRUNCATED_PAGE_CANCEL_REQ_T                      dm_truncated_page_cancel_req;
    DM_HCI_SET_CSB_RECEIVE_CFM_T                            dm_set_csb_receive_cfm;
    DM_HCI_SET_CSB_RECEIVE_REQ_T                            dm_set_csb_receive_req;
    DM_HCI_RECEIVE_SYNCHRONIZATION_TRAIN_CFM_T              dm_receive_synchronization_train_cfm;
    DM_HCI_RECEIVE_SYNCHRONIZATION_TRAIN_REQ_T              dm_receive_synchronization_train_req;
    DM_HCI_CSB_RECEIVE_IND_T                                dm_csb_received_ind;
    DM_HCI_CSB_TIMEOUT_IND_T                                dm_csb_timeout_ind;
    DM_HCI_CSB_CHANNEL_MAP_CHANGE_IND_T                     dm_csb_channel_map_change_ind;
    DM_HCI_SLAVE_PAGE_RESPONSE_TIMEOUT_IND_T                dm_slave_page_response_timeout_ind;
    DM_HCI_CSB_AFH_MAP_AVAILABLE_IND_T                      dm_csb_afh_map_available_ind;
    DM_HCI_CSB_TX_TIMEOUT_RSP_T                             dm_csb_tx_timeout_rsp;
    DM_HCI_CSB_RX_TIMEOUT_RSP_T                             dm_csb_rx_timeout_rsp;
    DM_CRYPTO_GENERATE_PUBLIC_PRIVATE_KEY_REQ_T             dm_crypto_generate_public_private_key_req;
    DM_CRYPTO_GENERATE_SHARED_SECRET_KEY_REQ_T              dm_crypto_generate_shared_key_req;
    DM_CRYPTO_ENCRYPT_REQ_T                                 dm_crypto_encrypt_req;
    DM_CRYPTO_DECRYPT_REQ_T                                 dm_crypto_decrypt_req;
    DM_CRYPTO_AES_CTR_REQ_T                                 dm_crypto_aes_ctr_req;
    DM_SM_SIRK_OPERATION_REQ_T                              dm_sm_sirk_operation_req;
    DM_SM_ENCRYPT_DATA_REQ_T                                dm_sm_encrypt_data_req;
    DM_CRYPTO_HASH_REQ_T                                    dm_crypto_hash_req;
    DM_CRYPTO_GENERATE_PUBLIC_PRIVATE_KEY_CFM_T             dm_crypto_generate_public_private_key_cfm;
    DM_CRYPTO_GENERATE_SHARED_SECRET_KEY_CFM_T              dm_crypto_generate_shared_secret_key_cfm;
    DM_CRYPTO_ENCRYPT_CFM_T                                 dm_crypto_encrypt_cfm;
    DM_CRYPTO_DECRYPT_CFM_T                                 dm_crypto_decrypt_cfm;
    DM_CRYPTO_AES_CTR_CFM_T                                 dm_crypto_aes_ctr_cfm;
    DM_SM_SIRK_OPERATION_CFM_T                              dm_sm_sirk_operation_cfm;
    DM_SM_ENCRYPT_DATA_CFM_T                                dm_sm_encrypt_data_cfm;
    DM_CRYPTO_HASH_CFM_T                                    dm_crypto_hash_cfm;
    DM_ULP_SET_PHY_REQ_T                                    dm_ulp_set_phy_req;
    DM_ULP_SET_PHY_CFM_T                                    dm_ulp_set_phy_cfm;
    DM_ULP_PHY_UPDATE_IND_T                                 dm_ulp_phy_update_ind;
    DM_ULP_SET_DEFAULT_PHY_REQ_T                            dm_ulp_set_default_phy_req;
    DM_ULP_SET_DEFAULT_PHY_CFM_T                            dm_ulp_set_default_phy_cfm;
    DM_ULP_READ_PHY_REQ_T                                   dm_ulp_read_phy_req;
    DM_ULP_READ_PHY_CFM_T                                   dm_ulp_read_phy_cfm;
    DM_WRITE_SC_HOST_SUPPORT_OVERRIDE_REQ_T                 dm_write_sc_host_support_override_req;
    DM_WRITE_SC_HOST_SUPPORT_OVERRIDE_CFM_T                 dm_write_sc_host_support_override_cfm;
    DM_READ_SC_HOST_SUPPORT_OVERRIDE_MAX_BD_ADDR_REQ_T      dm_read_sc_host_support_override_max_bd_addr_req;
    DM_READ_SC_HOST_SUPPORT_OVERRIDE_MAX_BD_ADDR_CFM_T      dm_read_sc_host_support_override_max_bd_addr_cfm;
    DM_HCI_ULP_EXT_ADV_SET_DATA_REQ_T                       dm_hci_ulp_set_ea_data_req;
    DM_HCI_ULP_EXT_ADV_SET_DATA_CFM_T                       dm_hci_ulp_set_ea_data_cfm;
    DM_HCI_ULP_EXT_ADV_SET_SCAN_RESP_DATA_REQ_T             dm_hci_ulp_set_ea_scan_resp_data_req;
    DM_HCI_ULP_EXT_ADV_SET_SCAN_RESP_DATA_CFM_T             dm_hci_ulp_set_ea_scan_resp_data_cfm;
    DM_ULP_GET_ADV_SCAN_CAPABILITIES_REQ_T                  dm_ulp_get_adv_scan_capabilities_req;
    DM_ULP_GET_ADV_SCAN_CAPABILITIES_CFM_T                  dm_ulp_get_adv_scan_capabilities_cfm;
    DM_ULP_SET_DATA_RELATED_ADDRESS_CHANGES_REQ_T           dm_ulp_set_data_related_address_changes_req;
    DM_ULP_SET_DATA_RELATED_ADDRESS_CHANGES_CFM_T           dm_ulp_set_data_related_address_changes_cfm;
    DM_ULP_EXT_ADV_SETS_INFO_REQ_T                          dm_ulp_ea_sets_info_req;
    DM_ULP_EXT_ADV_SETS_INFO_CFM_T                          dm_ulp_ea_sets_info_cfm;
    DM_ULP_EXT_ADV_REGISTER_APP_ADV_SET_REQ_T               dm_ulp_ea_register_app_adv_set_req;
    DM_ULP_EXT_ADV_REGISTER_APP_ADV_SET_CFM_T               dm_ulp_ea_register_app_adv_set_cfm;
    DM_ULP_EXT_ADV_UNREGISTER_APP_ADV_SET_REQ_T             dm_ulp_ea_unregister_app_adv_set_req;
    DM_ULP_EXT_ADV_UNREGISTER_APP_ADV_SET_CFM_T             dm_ulp_ea_unregister_app_adv_set_cfm;
    DM_ULP_EXT_ADV_SET_PARAMS_REQ_T                         dm_ulp_ea_set_params_req;
    DM_ULP_EXT_ADV_SET_PARAMS_CFM_T                         dm_ulp_ea_set_params_cfm;
    DM_ULP_EXT_ADV_SET_PARAMS_V2_REQ_T                      dm_ulp_ea_set_params_v2_req;
    DM_ULP_EXT_ADV_SET_PARAMS_V2_CFM_T                      dm_ulp_ea_set_params_v2_cfm;
    DM_ULP_EXT_ADV_ENABLE_REQ_T                             dm_ulp_ea_enable_req;
    DM_ULP_EXT_ADV_ENABLE_CFM_T                             dm_ulp_ea_enable_cfm;
    DM_ULP_EXT_ADV_MULTI_ENABLE_REQ_T                       dm_ulp_ea_multi_enable_req;
    DM_ULP_EXT_ADV_MULTI_ENABLE_CFM_T                       dm_ulp_ea_multi_enable_cfm;
    DM_ULP_EXT_ADV_GET_ADDR_REQ_T                           dm_ulp_ea_get_addr_req;
    DM_ULP_EXT_ADV_GET_ADDR_CFM_T                           dm_ulp_ea_get_addr_cfm;
    DM_ULP_EXT_ADV_READ_MAX_ADV_DATA_LEN_REQ_T              dm_ulp_ea_read_max_adv_data_len_req;
    DM_ULP_EXT_ADV_READ_MAX_ADV_DATA_LEN_CFM_T              dm_ulp_ea_read_max_adv_data_len_cfm;
    DM_ULP_EXT_ADV_SET_RANDOM_ADDR_REQ_T                    dm_ulp_ea_set_random_addr_req;
    DM_ULP_EXT_ADV_SET_RANDOM_ADDR_CFM_T                    dm_ulp_ea_set_random_addr_cfm;
    DM_HCI_ULP_PERIODIC_ADV_SET_DATA_REQ_T                  dm_hci_ulp_set_pa_data_req;
    DM_HCI_ULP_PERIODIC_ADV_SET_DATA_CFM_T                  dm_hci_ulp_set_pa_data_cfm;
    DM_ULP_PERIODIC_ADV_SET_PARAMS_REQ_T                    dm_ulp_pa_set_params_req;
    DM_ULP_PERIODIC_ADV_SET_PARAMS_CFM_T                    dm_ulp_pa_set_params_cfm;
    DM_ULP_PERIODIC_ADV_READ_MAX_ADV_DATA_LEN_REQ_T         dm_ulp_pa_read_max_adv_data_len_req;
    DM_ULP_PERIODIC_ADV_READ_MAX_ADV_DATA_LEN_CFM_T         dm_ulp_pa_read_max_adv_data_len_cfm;
    DM_ULP_PERIODIC_ADV_START_REQ_T                         dm_ulp_pa_start_req;
    DM_ULP_PERIODIC_ADV_START_CFM_T                         dm_ulp_pa_start_cfm;
    DM_ULP_PERIODIC_ADV_STOP_REQ_T                          dm_ulp_pa_stop_req;
    DM_ULP_PERIODIC_ADV_STOP_CFM_T                          dm_ulp_pa_stop_cfm;
    DM_ULP_PERIODIC_ADV_ENABLE_REQ_T                        dm_ulp_pa_enable_req;
    DM_ULP_PERIODIC_ADV_ENABLE_CFM_T                        dm_ulp_pa_enable_cfm;
    DM_ULP_PERIODIC_ADV_SET_TRANSFER_REQ_T                  dm_ulp_pa_set_transfer_req;
    DM_ULP_PERIODIC_ADV_SET_TRANSFER_CFM_T                  dm_ulp_pa_set_transfer_cfm;
    DM_ULP_EXT_SCAN_GET_GLOBAL_PARAMS_REQ_T                 dm_ulp_es_get_global_params_req;
    DM_ULP_EXT_SCAN_GET_GLOBAL_PARAMS_CFM_T                 dm_ulp_es_get_global_params_cfm;
    DM_ULP_EXT_SCAN_SET_GLOBAL_PARAMS_REQ_T                 dm_ulp_es_set_global_params_req;
    DM_ULP_EXT_SCAN_SET_GLOBAL_PARAMS_CFM_T                 dm_ulp_es_set_global_params_cfm;
    DM_ULP_EXT_SCAN_REGISTER_SCANNER_REQ_T                  dm_ulp_es_register_scanner_req;
    DM_ULP_EXT_SCAN_REGISTER_SCANNER_CFM_T                  dm_ulp_es_register_scanner_cfm;
    DM_ULP_EXT_SCAN_UNREGISTER_SCANNER_REQ_T                dm_ulp_es_unregister_req;
    DM_ULP_EXT_SCAN_UNREGISTER_SCANNER_CFM_T                dm_ulp_es_unregister_cfm;
    DM_ULP_EXT_SCAN_ENABLE_SCANNERS_REQ_T                   dm_ulp_es_enable_scanners_req;
    DM_ULP_EXT_SCAN_ENABLE_SCANNERS_CFM_T                   dm_ulp_es_enable_scanners_cfm;
    DM_ULP_EXT_SCAN_GET_CTRL_SCAN_INFO_REQ_T                dm_ulp_es_get_ctrl_scan_info_req;
    DM_ULP_EXT_SCAN_GET_CTRL_SCAN_INFO_CFM_T                dm_ulp_es_get_ctrl_scan_info_cfm;
    DM_ULP_EXT_SCAN_CTRL_SCAN_INFO_IND_T                    dm_ulp_es_ctrl_scan_info_ind;
    DM_ULP_EXT_SCAN_TIMEOUT_IND_T                           dm_ulp_es_scan_timeout_ind;
#ifndef EXCLUDE_AE_REPORTS
    DM_ULP_EXT_SCAN_FILTERED_ADV_REPORT_IND_T               dm_ulp_es_filtered_adv_report_ind;
#endif /* EXCLUDE_AE_REPORTS */
    DM_ULP_PERIODIC_SCAN_START_FIND_TRAINS_REQ_T            dm_ulp_ps_start_find_trains_req;
    DM_ULP_PERIODIC_SCAN_START_FIND_TRAINS_CFM_T            dm_ulp_ps_start_find_trains_cfm;
    DM_ULP_PERIODIC_SCAN_STOP_FIND_TRAINS_REQ_T             dm_ulp_ps_stop_find_trains_req;
    DM_ULP_PERIODIC_SCAN_STOP_FIND_TRAINS_CFM_T             dm_ulp_ps_stop_find_trains_cfm;
    DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_REQ_T                dm_ulp_ps_sync_to_train_req;
    DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CFM_T                dm_ulp_ps_sync_to_train_cfm;
    DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CANCEL_REQ_T         dm_ulp_ps_sync_to_train_cancel_req;
    DM_ULP_PERIODIC_SCAN_SYNC_TO_TRAIN_CANCEL_CFM_T         dm_ulp_ps_sync_to_train_cancel_cfm;
    DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_ENABLE_REQ_T       dm_ulp_ps_sync_adv_report_enable_req;
    DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_ENABLE_CFM_T       dm_ulp_ps_sync_adv_report_enable_cfm;
    DM_ULP_PERIODIC_SCAN_SYNC_TERMINATE_REQ_T               dm_ulp_ps_sync_terminate_req;
    DM_ULP_PERIODIC_SCAN_SYNC_TERMINATE_CFM_T               dm_ulp_ps_sync_terminate_cfm;
#ifndef EXCLUDE_AE_REPORTS
    DM_ULP_PERIODIC_SCAN_SYNC_ADV_REPORT_IND_T              dm_ulp_ps_sync_adv_report_ind;
#endif /* EXCLUDE_AE_REPORTS */
    DM_ULP_PERIODIC_SCAN_SYNC_LOST_IND_T                    dm_ulp_ps_sync_lost_ind;
    DM_ULP_PERIODIC_SCAN_SYNC_LOST_RSP_T                    dm_ulp_ps_sync_lost_rsp;
    DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_REQ_T                dm_ulp_ps_sync_transfer_req;
    DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_CFM_T                dm_ulp_ps_sync_transfer_cfm;
    DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_IND_T                dm_ulp_ps_sync_transfer_ind;
    DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_PARAMS_REQ_T         dm_ulp_ps_sync_transfer_params_req;
    DM_ULP_PERIODIC_SCAN_SYNC_TRANSFER_PARAMS_CFM_T         dm_ulp_ps_sync_transfer_params_cfm;
    DM_ULP_EXT_SCAN_DURATION_EXPIRED_IND_T                  dm_ulp_es_duration_expired_ind;
    DM_ULP_EXT_ADV_TERMINATED_IND_T                         dm_ulp_ea_terminated_ind;
    DM_ULP_ENHANCED_READ_TRANSMIT_POWER_LEVEL_REQ_T         dm_ulp_enhanced_read_transmit_power_level_req;
    DM_ULP_ENHANCED_READ_TRANSMIT_POWER_LEVEL_CFM_T         dm_ulp_enhanced_read_transmit_power_level_cfm;
    DM_ULP_READ_REMOTE_TRANSMIT_POWER_LEVEL_REQ_T           dm_ulp_read_remote_transmit_power_level_req;
    DM_ULP_READ_REMOTE_TRANSMIT_POWER_LEVEL_CFM_T           dm_ulp_read_remote_transmit_power_level_cfm;
    DM_ULP_TRANSMIT_POWER_REPORTING_IND_T                   dm_ulp_transmit_power_reporting_ind;
    DM_ULP_SET_PATH_LOSS_REPORTING_PARAMETERS_REQ_T         dm_ulp_set_path_loss_reporting_parameters_req;
    DM_ULP_SET_PATH_LOSS_REPORTING_PARAMETERS_CFM_T         dm_ulp_set_path_loss_reporting_parameters_cfm;
    DM_ULP_SET_PATH_LOSS_REPORTING_ENABLE_REQ_T             dm_ulp_set_path_loss_reporting_enable_req;
    DM_ULP_SET_PATH_LOSS_REPORTING_ENABLE_CFM_T             dm_ulp_set_path_loss_reporting_enable_cfm;
    DM_ULP_SET_TRANSMIT_POWER_REPORTING_ENABLE_REQ_T        dm_ulp_set_transmit_power_reporting_enable_req;
    DM_ULP_SET_TRANSMIT_POWER_REPORTING_ENABLE_CFM_T        dm_ulp_set_transmit_power_reporting_enable_cfm;
    DM_ULP_PATH_LOSS_THRESHOLD_IND_T                        dm_ulp_path_loss_threshold_ind;

    DM_ISOC_REGISTER_REQ_T                                  dm_isoc_register_req;
    DM_ISOC_REGISTER_CFM_T                                  dm_isoc_register_cfm;
    DM_ISOC_CONFIGURE_CIG_REQ_T                             dm_isoc_configure_cig_req;
    DM_ISOC_CONFIGURE_CIG_CFM_T                             dm_isoc_configure_cig_cfm;
    DM_ISOC_CONFIGURE_CIG_TEST_REQ_T                        dm_isoc_configure_cig_test_req;
    DM_ISOC_CONFIGURE_CIG_TEST_CFM_T                        dm_isoc_configure_cig_test_cfm;
    DM_ISOC_CIS_CONNECT_REQ_T                               dm_isoc_cis_connect_req;
    DM_ISOC_CIS_CONNECT_IND_T                               dm_isoc_cis_connect_ind;
    DM_ISOC_CIS_CONNECT_RSP_T                               dm_isoc_cis_connect_rsp;
    DM_ISOC_CIS_CONNECT_CFM_T                               dm_isoc_cis_connect_cfm;
    DM_ISOC_CIS_DISCONNECT_REQ_T                            dm_isoc_cis_disconnect_req;
    DM_ISOC_CIS_DISCONNECT_CFM_T                            dm_isoc_cis_disconnect_cfm;
    DM_ISOC_CIS_DISCONNECT_IND_T                            dm_isoc_cis_disconnect_ind;
    DM_ISOC_REMOVE_CIG_REQ_T                                dm_isoc_remove_cig_req;
    DM_ISOC_REMOVE_CIG_CFM_T                                dm_isoc_remove_cig_cfm;
    DM_ISOC_CREATE_BIG_REQ_T                                dm_isoc_create_big_req;
    DM_ISOC_CREATE_BIG_CFM_T                                dm_isoc_create_big_cfm;
    DM_ISOC_CREATE_BIG_TEST_REQ_T                           dm_isoc_create_big_test_req;
    DM_ISOC_CREATE_BIG_TEST_CFM_T                           dm_isoc_create_big_test_cfm;
    DM_ISOC_TERMINATE_BIG_REQ_T                             dm_isoc_terminate_big_req;
    DM_ISOC_TERMINATE_BIG_CFM_T                             dm_isoc_terminate_big_cfm;
    DM_ISOC_BIG_CREATE_SYNC_REQ_T                           dm_isoc_big_create_sync_req;
    DM_ISOC_BIG_CREATE_SYNC_CFM_T                           dm_isoc_big_create_sync_cfm;
    DM_ISOC_BIG_TERMINATE_SYNC_REQ_T                        dm_isoc_big_terminate_sync_req;
    DM_ISOC_BIG_TERMINATE_SYNC_IND_T                        dm_isoc_big_terminate_sync_ind;
    DM_HCI_ULP_BIGINFO_ADV_REPORT_IND_T                     dm_isoc_biginfo_adv_report_ind;
    DM_ISOC_ISO_TRANSMIT_TEST_REQ_T                         dm_isoc_iso_transmit_req;
    DM_ISOC_ISO_TRANSMIT_TEST_CFM_T                         dm_isoc_iso_transmit_cfm;
    DM_ISOC_ISO_RECEIVE_TEST_REQ_T                          dm_isoc_iso_receive_req;
    DM_ISOC_ISO_RECEIVE_TEST_CFM_T                          dm_isoc_iso_receive_cfm;
    DM_ISOC_ISO_READ_TEST_COUNTERS_REQ_T                    dm_isoc_iso_read_test_counters_req;
    DM_ISOC_ISO_READ_TEST_COUNTERS_CFM_T                    dm_isoc_iso_read_test_counters_cfm;
    DM_ISOC_SETUP_ISO_DATA_PATH_REQ_T                       dm_isoc_setup_iso_data_path_req;
    DM_ISOC_SETUP_ISO_DATA_PATH_CFM_T                       dm_isoc_setup_iso_data_path_cfm;
    DM_ISOC_REMOVE_ISO_DATA_PATH_REQ_T                      dm_isoc_remove_iso_data_path_req;
    DM_ISOC_REMOVE_ISO_DATA_PATH_CFM_T                      dm_isoc_remove_iso_data_path_cfm;
    DM_ISOC_READ_ISO_LINK_QUALITY_REQ_T                     dm_isoc_read_iso_link_quality_req;
    DM_ISOC_READ_ISO_LINK_QUALITY_CFM_T                     dm_isoc_read_iso_link_quality_cfm;
    DM_ISOC_BROADCAST_DEVICE_SECURITY_REQ_T                 dm_isco_broadcast_dev_sec_req;
    DM_ISOC_BROADCAST_DEVICE_SECURITY_CFM_T                 dm_isco_broadcast_dev_sec_cfm;

    DM_HCI_ULP_SET_DEFAULT_SUBRATE_REQ_T                    dm_hci_ulp_set_default_subreate_req;
    DM_HCI_ULP_SET_DEFAULT_SUBRATE_CFM_T                    dm_hci_ulp_set_default_subreate_cfm;
    DM_HCI_ULP_SUBRATE_CHANGE_REQ_T                         dm_hci_ulp_subrate_change_req;
    DM_HCI_ULP_SUBRATE_CHANGE_CFM_T                         dm_hci_ulp_subrate_change_cfm;
    DM_HCI_ULP_SUBRATE_CHANGE_IND_T                         dm_hci_ulp_subrate_change_ind;
} DM_UPRIM_T;

/*============================================================================*
 *                               PUBLIC FUNCTIONS
 *============================================================================*/
/* None */

#ifdef __cplusplus
}
#endif

/*=============================== END OF FILE ================================*/
#endif /* ndef _DM_PRIM_H */
